R
Rob G
Hello,
I would like to refer to a subform using a variable, but I can't seem to get
the syntax correct.
For example, I want my code to look through each control on a subform, I
have the following code:
Function PrintControlNames(MainFormVariable As String, SubFormStringVariable
As String)
For Each ctr In Forms(MainFormVariable).(SubFormStringVariable).Controls
Debug.Print ctr.Name
Next
End Function
The code is fine with the MainFormVariable, but unless I explicitly put the
name of the SubForm (where the SubFormStringVariable is), I get an error
that it can't find the subform.
Any ideas?
Thanks.
-Rob
I would like to refer to a subform using a variable, but I can't seem to get
the syntax correct.
For example, I want my code to look through each control on a subform, I
have the following code:
Function PrintControlNames(MainFormVariable As String, SubFormStringVariable
As String)
For Each ctr In Forms(MainFormVariable).(SubFormStringVariable).Controls
Debug.Print ctr.Name
Next
End Function
The code is fine with the MainFormVariable, but unless I explicitly put the
name of the SubForm (where the SubFormStringVariable is), I get an error
that it can't find the subform.
Any ideas?
Thanks.
-Rob