Link to home
Start Free TrialLog in
Avatar of dsoderstrom
dsoderstrom

asked on

Subform is not refreshing after update

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.
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Try with:

    Me!subformname.Form.Requery

/gustav
Avatar of Gauthier
Gauthier

Well it should work.
maybe me!subformname.requery in case you do something odd (like adding the subform dynamically)
Avatar of dsoderstrom

ASKER

Tried both suggestions. subform still does not update.
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...
ok, tested your case, and for me the got focus is not triggered at all.
you must use on activate instead of on got focus
or use my first workaround
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did it!  works perfectly.
Thank you very much.
You are welcome!

/gustav