best place to requery (1 Viewer)

Lanason

Registered User.
Local time
Today, 06:10
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:
 

isladogs

MVP / VIP
Local time
Today, 06:10
Joined
Jan 14, 2017
Messages
18,216
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
 

Lanason

Registered User.
Local time
Today, 06:10
Joined
Sep 12, 2003
Messages
258
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
 

Minty

AWF VIP
Local time
Today, 06:10
Joined
Jul 26, 2013
Messages
10,371
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:10
Joined
Feb 28, 2001
Messages
27,172
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
 

Lanason

Registered User.
Local time
Today, 06:10
Joined
Sep 12, 2003
Messages
258
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
 

Lanason

Registered User.
Local time
Today, 06:10
Joined
Sep 12, 2003
Messages
258
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 !!
 

Minty

AWF VIP
Local time
Today, 06:10
Joined
Jul 26, 2013
Messages
10,371
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

Top Bottom