Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requery a subform from another form?

I've struggling with this problem on my own, then with some help, then search about it; but I haven't had any luck. So I decided to ask.

I have two forms in Access 2007 lets call them MainForm and EntryForm.
MainForm has a subform and a button. The button opens the EntryForm in Add Mode. What I want to do is when the EntryForm saves the new record it would update (requery) the subform in MainForm.

I've try this setup code

Private Sub cmdSaveAndClose_Click()
    DoCmd.Save

    'requery list
    Forms![MainForm]![subformName].Requery

    '' I've also tried these
    'Forms![MainForm]![subformName].Form.Requery
    'Forms.("MainForm").[subformName].Requery
    'Forms.("MainForm").[subformName].Form.Requery


    DoCmd.Close
End Sub

None of these attempts seem to work. Is there a way to make this requery? Thanks for the help in advance.

like image 821
Tony L. Avatar asked Dec 18 '09 16:12

Tony L.


People also ask

How do I requery a subform from another form in Access?

On the main form look at the label the subform wizard provided or select the subform by clicking once or on the border around it and look at the "caption" in the "Other" tab in properties. That's the name you use for requerying, not the name of the form that appears in the navigation panel.


1 Answers

You must use the name of the subform control, not the name of the subform, though these are often the same:

 Forms![MainForm]![subform control name Name].Form.Requery

Or, if you are on the main form:

 Me.[subform control name Name].Form.Requery

More Info: http://www.mvps.org/access/forms/frm0031.htm

like image 135
Fionnuala Avatar answered Sep 20 '22 08:09

Fionnuala