Results 1 to 3 of 3
  1. #1
    BCJourney is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46

    Requery unrelated form when another form closes


    I have an unbound main form [main1] with a combo box, subform [subcount], and a button. The [subcount] displays a count of records for a query [30_day_qry] based on the selection in the combo box. When the button is clicked it opens a form [data_entry] that displays the results of the same query [30_day_qry] and contains a subform [input] for user input that gets saved to a table. After entering data the save button is clicked then the exit button. The form closes and you are back to the main form.

    Everything works fine except that once records are changed in the subform [input], the count of records for that query usually changes. But that count doesn't change in the subform [subcount] on the main form [main1] after that query form [data_entry] is closed. I have to select another item from the drop down list to requery the suboform [subcount] or close the main form [main1] and re-open it to make the counts correct again.

    I've tried to do requery in the on close event of the query form [data_entry] but nothing seems to work. I noticed that user input probably isn't saving to the table until the form is closed.

    I know it sounds confusing, any help is appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The requery code in close event should work. However, can put the code on [main1] instead. Open the [data_entry] in Dialog mode. This will suspend code execution in [main1] until [data_entry] is closed.

    DoCmd.OpenForm "data_entry", , , , , acDialog
    Me.subcount.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    BCJourney is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46
    You are a genius! I can't thank you enough.

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

Similar Threads

  1. cell from table to unrelated form
    By Justin Warner in forum Forms
    Replies: 3
    Last Post: 01-01-2012, 08:06 PM
  2. Get Focus on Form after Modal Form closes
    By TinaCa in forum Programming
    Replies: 2
    Last Post: 09-06-2011, 04:47 PM
  3. Form closes after mssage box
    By liam01752 in forum Programming
    Replies: 1
    Last Post: 12-06-2010, 03:30 PM
  4. Displaying unrelated data on a form
    By FadingAPE in forum Forms
    Replies: 1
    Last Post: 10-06-2010, 10:33 AM
  5. Change to Form Closes Access
    By jbhjm in forum Forms
    Replies: 5
    Last Post: 04-22-2009, 01:04 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