Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MS Access - Form_Load and SubForm issue

Options
  • 20-01-2009 3:17pm
    #1
    Registered Users Posts: 2,598 ✭✭✭


    Having a bit of trouble with an MS Access form and a subform running off a query so any help would be appreciated.

    Deal is:
    Form displays a textbox with a reference number in it.

    Subform source is a query, with the WHERE clause criteria based on the reference number on the main form.

    Reference Number is set on Form_Load, Current and Activate events.

    When I open the main form directly there is no problem however when I open it from another form,
    the subform seems to trigger before the main Form_Load gets to set the Reference.
    So it displays an InputBox to get the value before the form_Load actually populates it.

    (Not sure if all that makes sence!?!)
    Any ideas?


Comments

  • Moderators Posts: 51,799 ✭✭✭✭Delirium


    Could you not populate the value into a global variable. That way you could set the subform WHERE clause to use a function that returns the variable.

    Example
    Global gblIDProduct AS Integer
    
    Function GetGblIDProduct()
      GetGblIDProduct = gblIDProduct
    End Function
    

    Then the WHERE Clause could use the following syntax
    SELECT tblProduct.* FROM tblProduct
    WHERE idProduct = GetGblIDProduct()
    

    Hope that helps:)

    If you can read this, you're too close!



Advertisement