Referring to a control on a subform in a class module

  • Thread starter Thread starter JimP
  • Start date Start date
J

JimP

This seems to work, but is it correct? Main form, sub form and control are
all variables.

set ctl = Forms(MainForm).Controls(SubForm).Form.Controls(ControlName)
 
JimP said:
This seems to work, but is it correct? Main form, sub form and control are
all variables.

set ctl = Forms(MainForm).Controls(SubForm).Form.Controls(ControlName)


Yes, that is correct, even formal.

Since Controls is the default property of form objects, it
is not required so this would also be acceptable:

Set ctl = Forms(MainForm)(SubForm).Form(ControlName)

You'll have to decide if you want to use a rigorous or
relaxed coding style.
 
Back
Top