Reference a subform control

  • Thread starter Thread starter Todd Lemen
  • Start date Start date
T

Todd Lemen

Is there a VBA syntax for referencing a subcontrol form,
using Form("Form name").Controls("control name")
notation? I'd like to pass the form name and control to
a small form on open, then use those form and control
names to pass back the result. I can get the Forms!
[FormName]![Subform name].Form![Control Name] notation to
work, but would like to use variables for the form and
control names (hence the preference for the Form("Form
name").Controls("control name") notation).

Todd Lemen
 
Hi Todd

The ![MemberName] part can always be replaced by ("MemberName").

So, Forms![FormName]![SubformControlName].Form![ControlName]
becomes:

Forms("FormName")("SubformControlName").Form("ControlName")

Any of the quoted strings may be replaced by a variable, or even a string
expression.

Note that the .Controls bit is implied twice here - between the )( and after
..Form - but they are both unnecessary because .Controls if the default
collection for a Form object.
 
Thanks, Graham!
TL
-----Original Message-----
Hi Todd

The ![MemberName] part can always be replaced by ("MemberName").

So, Forms![FormName]![SubformControlName].Form! [ControlName]
becomes:

Forms("FormName")("SubformControlName").Form
("ControlName")

Any of the quoted strings may be replaced by a variable, or even a string
expression.

Note that the .Controls bit is implied twice here - between the )( and after
..Form - but they are both unnecessary because .Controls if the default
collection for a Form object.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Is there a VBA syntax for referencing a subcontrol form,
using Form("Form name").Controls("control name")
notation? I'd like to pass the form name and control to
a small form on open, then use those form and control
names to pass back the result. I can get the Forms!
[FormName]![Subform name].Form![Control Name] notation to
work, but would like to use variables for the form and
control names (hence the preference for the Form("Form
name").Controls("control name") notation).

Todd Lemen


.
 
Todd said:
Is there a VBA syntax for referencing a subcontrol form,
using Form("Form name").Controls("control name")
notation? I'd like to pass the form name and control to
a small form on open, then use those form and control
names to pass back the result. I can get the Forms!
[FormName]![Subform name].Form![Control Name] notation to
work, but would like to use variables for the form and
control names (hence the preference for the Form("Form
name").Controls("control name") notation).


Forms(strMainFormName).Controls(strSubformControlName).Form.Controls(strControlOnSubform)
 
Back
Top