Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

MS Access - Form_Load and SubForm issue

  • 20-01-2009 03:17PM
    #1
    Registered Users, Registered Users 2 Posts: 2,602 ✭✭✭


    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: 52,119 ✭✭✭✭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