Requery Multiple Subforms

  • Thread starter Thread starter NEWER USER
  • Start date Start date
N

NEWER USER

I have an unbound form with a subform. (frmTotals and fsubTotals1). I have a
toolbar with a Function named Requery. I push the command on the Toolbar and
the subform is refreshed. My code is
Function Requery()
On Error GoTo Requery_Err
DoCmd.Requery

Requery_Exit:
Exit Function

Requery_Err:
MsgBox Err.Description
Resume Requery_Exit

End Function

I want to add two additional subforms fsubTotals2 and fsubTotals3 to display
the data differently. I have changed the code and getting error messages; I
have tried getting rid of the Function altogether and creating the command
button in the forms Module as well. Error messages state that the Field can
not be found. I have tried a few scenarios with NO LUCK.

Me![Mfg].Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].Form.Requery '(fsubTotals3) Brand is a field on form

Me![Mfg].fsubTotals1.Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].fsubTotals1.Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].fsubTotals1.Form.Requery '(fsubTotals3) Brand is a field on form

Ideally. I would like to stick with the Toolbar Function and not the command
button on the form. Me! did not work in the function. Any help in the right
direction is appreciated. Thanks
 
NEWER said:
I have an unbound form with a subform. (frmTotals and fsubTotals1). I have a
toolbar with a Function named Requery. I push the command on the Toolbar and
the subform is refreshed. My code is
Function Requery()
On Error GoTo Requery_Err
DoCmd.Requery

Requery_Exit:
Exit Function

Requery_Err:
MsgBox Err.Description
Resume Requery_Exit

End Function

I want to add two additional subforms fsubTotals2 and fsubTotals3 to display
the data differently. I have changed the code and getting error messages; I
have tried getting rid of the Function altogether and creating the command
button in the forms Module as well. Error messages state that the Field can
not be found. I have tried a few scenarios with NO LUCK.

Me![Mfg].Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].Form.Requery '(fsubTotals3) Brand is a field on form

Me![Mfg].fsubTotals1.Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].fsubTotals1.Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].fsubTotals1.Form.Requery '(fsubTotals3) Brand is a field on form

Ideally. I would like to stick with the Toolbar Function and not the command
button on the form. Me! did not work in the function. Any help in the right
direction is appreciated. Thanks


The general syntax to requery a subform from outside the
main/sub form structure is:

Forms!mainform.subformcontrol.Form.Requery

If your subform controls are named the same as the form
objects displayed in the controls, the command bar function
could look like:

With Forms!mainform
.fsubTotals1.Form.Requery
.fsubTotals2.Form.Requery
.fsubTotals3.Form.Requery
End With
 
Thank you for help; worked to perfection

Marshall Barton said:
NEWER said:
I have an unbound form with a subform. (frmTotals and fsubTotals1). I have a
toolbar with a Function named Requery. I push the command on the Toolbar and
the subform is refreshed. My code is
Function Requery()
On Error GoTo Requery_Err
DoCmd.Requery

Requery_Exit:
Exit Function

Requery_Err:
MsgBox Err.Description
Resume Requery_Exit

End Function

I want to add two additional subforms fsubTotals2 and fsubTotals3 to display
the data differently. I have changed the code and getting error messages; I
have tried getting rid of the Function altogether and creating the command
button in the forms Module as well. Error messages state that the Field can
not be found. I have tried a few scenarios with NO LUCK.

Me![Mfg].Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].Form.Requery '(fsubTotals3) Brand is a field on form

Me![Mfg].fsubTotals1.Form.Requery '(fsubTotals1) Mfg is a field on the form
Me![Type].fsubTotals1.Form.Requery '(fsubTotals2) Type is a field on the form
Me.[Brand].fsubTotals1.Form.Requery '(fsubTotals3) Brand is a field on form

Ideally. I would like to stick with the Toolbar Function and not the command
button on the form. Me! did not work in the function. Any help in the right
direction is appreciated. Thanks


The general syntax to requery a subform from outside the
main/sub form structure is:

Forms!mainform.subformcontrol.Form.Requery

If your subform controls are named the same as the form
objects displayed in the controls, the command bar function
could look like:

With Forms!mainform
.fsubTotals1.Form.Requery
.fsubTotals2.Form.Requery
.fsubTotals3.Form.Requery
End With
 
Back
Top