Results 1 to 4 of 4
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    requery subform after "on load" event?


    Hey ppls,

    Probably an easy question but ive tried afew things and no luck!

    When my db opens, i run a module which checks if certain criteria are being met by my data.
    In this case, have certain settlements occured today that arent marked as "settled"

    Anyway, the code works fine, and i have it "on load' instead of Current as i only want it to fire once each time the program is opened.

    the issue is that the main page subform runs off data and looks at UNSETTLED data...

    I run the code onload, it registers dates and makes the correct data settled now, but the subform is still looking at the data bfore the changes occured. If i go away from the page and come back it is correct!

    So i tried doing me.navigationsubform.requery and it doesnt work.

    What am i doing wrong and can i get any opinions/ideas please

    Thanks in advance!
    Gangel

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    If the startup code doesn't require any data fields from the form to work properly, check out the autoexec macro. It will run code at startup. Have that code do its thing and then have it load the form. If you do it this way, remove the form name from the Access Options 'Display Form:'.
    Last edited by davegri; 06-03-2016 at 03:15 PM. Reason: clarity

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    When a Form has a Subform, the order of events, on opening, is
    Open Subform
    Load Subform
    Current Subform

    Open Main Form
    Load Main Form
    Current Main Form


    I'm not sure I understand your scenario, and it may be that davegri's suggestion will work, but it sounds as if you need the OnLoad event of the Subform to run again after the Main Form has loaded, rather than Requerying the Subform. If so, I'd Call the OnLoad event of the Subform as the last line of the OnLoad event of the Main Form.

    Linq ;0)>

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Records are being changed...
    I run the code onload, it registers dates and makes the correct data settled now, but the subform is still looking at the data bfore the changes occured
    This is not how you requery a subform: me.navigationsubform.requery
    I believe the syntax is something like
    Code:
    Forms("MainFormName").Controls("subformControlName").Form.Requery
    NOTE: subformControlName is not the name of your sub form, but the control that contains it
    The reason it works when you close and reopen is that the forms naturally become in sync again.
    EDIT: I would requery the subform, not reload it. No telling what can happen to the form data by doing that since no code was provided.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 3
    Last Post: 02-06-2015, 03:22 PM
  3. Replies: 7
    Last Post: 12-21-2014, 08:21 PM
  4. Replies: 2
    Last Post: 01-15-2014, 07:57 PM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums