A family of Microsoft relational database management systems designed for ease of use.
How about:
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is SubForm Then
ctl.Requery
End If
Next ctl
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a form with 5 subforms nested together in one parent form
The code on the activate event of the parent form requeries the first subform1 and subform1 requires subform2 and so on with the requery code on each underlying form's current event.
when I add or edit data, the whole subforms reflect the changes. But when I delete all the displayed records, all subforms are supposed to go blank, but only subform1 does. Unless I requerry all the subforms.
I need a better way to write a code to requery all the subforms at once instead of:
subform1.Requery
subform2.Requery
subform3.Requery
subform4.Requery
subform5.Requery
Thank you all
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
How about:
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is SubForm Then
ctl.Requery
End If
Next ctl
Docmd.showallrecords
For what it's worth, requerying the mainform will requery all the subforms.
Of course that will ALSO move the mainform to the first record of the recordset, and probably have other effects as well, so it might not be what you want!
Thanks for your reply.
I thought there should be a better way to write the code to perform that action.
so even if I have up 10 subforms, I will keep writing:
Subform1.Requery, Subform2.Requery and so on.
That seems redundant.
What would you consider "a better way"? I see nothing wrong with the above code.