Results 1 to 4 of 4
  1. #1
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114

    Requery multiple sub forms when clicking Print button on the main form

    I have a primary form with 6 sub forms. The data gets entered and then you can click a button to print the report. My problem is that the report is not getting the most recent changes because the report query isn't running after the data is updated.



    I'm guessing a requery is the way to go but I'm not sure if I have to do a requery for each sub form, or if I can incorporate it into the VBA for the "On Click" event. What's the best/efficient way to perform a requery?

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The requery is ONLY needed to see data on the form. Opening a report actually does the requery for the report.
    Are you opening the report using KEY ID for that master record?
    Is all the data in the sub form 'saved'? (no in edit mode, 'pencil' on the data record)

    Once you saved the data, and pull data from the key, the query will pull all data.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    When you edit data in a form, the form's recordset is updated. If you want to commit the changes to the table(s), you need to save the form. Saving the main form may be enough. So if you have a print report button on the Main Form you would add something like the following before the code that opens the report.
    Code:
    If Me.Dirty = True then
    Me.dirty = false
    End If
    Depending on the properties of the Main Form and Subforms, you may need to save each of the subforms, too.

  4. #4
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    I thought I had responded to this, sorry for the long delay.

    I inserted the code supplied by ItsMe into the main form. Now all the sub forms update before the report runs.

    Solved!

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

Similar Threads

  1. Replies: 2
    Last Post: 09-15-2015, 03:08 AM
  2. Multiple Sub-Forms in a main form for editing
    By Harley Guy in forum Forms
    Replies: 1
    Last Post: 12-19-2013, 12:54 PM
  3. Replies: 17
    Last Post: 08-22-2013, 08:22 AM
  4. Replies: 3
    Last Post: 04-17-2012, 10:28 AM
  5. Replies: 1
    Last Post: 03-31-2012, 01:38 PM

Tags for this Thread

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