Help with Requery

D

David Ehrenreich

I would like to requery a subform from another form. I
have forms in two seperate mdf files, and tables in
another(Frm1, Frm2) and i need frm1 to requery form 2
afterupdate. I have tried this method, but only works
when the form is in the same file.

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("frm2").IsLoaded Then

Forms![frm2]![frm2Sbfrm.Requery

End If

End Sub

I was wondering if currentProject has something to do
with
it?

Any help would be great.

Thank you
David Ehrenreich

..
 
W

Wayne Morgan

The CurrentProject does have something to do with it. A subform won't show
up as IsLoaded. You need to see if the parent form is loaded then requery
from there. If the parent form is Frm1

Forms!Frm1!NameOfSubformControl.Form.Requery

The NameOfSubformControl is the name of the control on the main form that
holds the subform, not the name of the subform itself. However, if you
create the subform by drag and drop, by default Access will give the subform
control the same name as the subform it contains.
 
M

Mike

You could also refresh by:

SendKeys String:="{F9}", Wait:=True

accomplish the same thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top