best place to requery

Lanason

Registered User.
Local time
Today, 08:29
Joined
Sep 12, 2003
Messages
258
I am opening a subform to change detail and then closing the subform to go back to the summary form.

what is the best place to put the Me.Requery code

is it on load / activate /open / ongotfocus ........:banghead:
 
It depends on other things in your form - in other words try it & see...

However, no point putting it in Form_Open or Load as both of those have already been done...

Form_Activate may work or use Form_Current

If its a list box you want updating you may need to specify that
e.g. Me.ListBox.Requery

NOTE: Refresh may do the job instead

Finally in very rare cases, I've resorted to the following to update the main form

Code:
Application.Echo False
DoCmd.Close acForm "MainFormName"
DoCmd.Open "MainFormName"
Application.Echo True

The application echo is used to prevent the screen updating whilst the form is closed & reopened
 
Thanks guessed it probably wasn't open or load

but activate / focus etc are a bit more confusing

its just a summary table where the data has been changed in the detail
 
I would requery the summary form on the closing event of the update sub form.

[Forms]![Your_Form_Name].Requery

If it really a subform and you are hiding it on the main form, then Me.Parent.Requery should do the job.
 
Concur with Minty. Using a GotFocus is tenuous at best since you have to be sure as to which control on the parent would get focus. Form_Activate should be a good choice but if you change windows because you had more than one form open, you would get a phantom activation. It wouldn't hurt but the _Activate routine would have to be more narrowly crafted.

Do it when the child form is closing using Me.Parent.Refresh or .Requery
 
Maybe my terminology is confusing

The main form is in the form of a list of records
the other form is a totally separate form and contain the detail for just one record - is it connected using a linked field

So not and parent /subform in the context of a single form design
 
main problem is I have different lists that call up the same detail form :-(
so requerying in the child would depend upon which parent opened it !!
 
If it's a totally separate form then pass the calling form in using OpenArgs . Use that to determine the form you are refreshing on the close event.
 

Users who are viewing this thread

Back
Top Bottom