Solved

Subform is not refreshing after update

Posted on 2014-12-21
9
148 Views
Last Modified: 2014-12-22
I have a main form with one subform.  The subform is based upon a query and is linked to the main form based upon two fields.
I have a command button on the main form that brings up a second form that allows me to make changes or additions to the table that the query for the subform on the first form is based on.  When this form closes the first form again gets focus but the changes or additions made to the table do not appear on the subform.  If I move to another record on the main form and then go back to the original record, the changes/additions then show up on the subform.I have tried using the following code to the "On Got Focus" event of the Main form but it does not make a difference:
         Me.subformname.requery
         Me.Refresh
Any help would be greatly appreciated.
0
Comment
Question by:dsoderstrom
  • 4
  • 3
  • 2
9 Comments
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40511749
Try with:

    Me!subformname.Form.Requery

/gustav
0
 
LVL 7

Expert Comment

by:Gauthier
ID: 40511754
Well it should work.
maybe me!subformname.requery in case you do something odd (like adding the subform dynamically)
0
 

Author Comment

by:dsoderstrom
ID: 40511986
Tried both suggestions. subform still does not update.
0
 
LVL 7

Expert Comment

by:Gauthier
ID: 40511996
Other possibilities:
- Check that your on got focus the event is fired (add a debug.print or a breakpoint).

Workaround:
trigger the other subform Requery (if it is opened) in the after_Update of the closing form.
Note that the event normally fire in this order:
After_Update
Close
so the got focus event is normally fired well after the save...
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 7

Expert Comment

by:Gauthier
ID: 40512013
ok, tested your case, and for me the got focus is not triggered at all.
0
 
LVL 7

Expert Comment

by:Gauthier
ID: 40512017
you must use on activate instead of on got focus
or use my first workaround
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40512019
Use the OnActivate event.

/gustav
0
 

Author Closing Comment

by:dsoderstrom
ID: 40512132
That did it!  works perfectly.
Thank you very much.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40512481
You are welcome!

/gustav
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now