Referring to a control on a subform in a class module

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)
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top