Requery a subform using a variable (1 Viewer)

Trocergian

Registered User.
Local time
Today, 10:39
Joined
Apr 6, 2009
Messages
16
I'm attempting to requery a subform using a variable and running into "can't find form" errors.

Here's code that works fine when run directly:
Forms!frmDashboard!frmDwgStatusSub.Form.Requery

But when loaded into a variable and trying to run via:
Forms(gSendingForm).Requery
throws an error.

I've attempted:
gSendingForm = "Forms!frmDashboard!frmDwgStatusSub.Form"
and
gSendingForm = "frmDashboard!frmDwgStatusSub.Form"
and
gSendingForm = "frmDashboard!frmDwgStatusSub"
with no luck.

I can use Forms(gSendingForm).Requery (ex. gSendingForm = "frmDashboard") to requery any top level form so I'm guessing that command is not the problem.

What am I missing?
 

sneuberg

AWF VIP
Local time
Today, 08:39
Joined
Oct 17, 2014
Messages
3,506
You can do it like:


Code:
Forms("NameOfMainForm").Controls("NameOfSubformControl").Form.Requery
where the strings "NameOfMainForm" and "NameOfSubformControl" could be replace by string variables.

Code:
Forms("NameOfMainForm")("NameOfSubformControl").Form.Requery

works too. And in the forms module just

Code:
Me("NameOfSubformControl").Form.Requery
 
Last edited:

Users who are viewing this thread

Top Bottom