Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I reference a control (or form/report) using a variable?

Referencing Controls

How do I reference a control (or form/report) using a variable?

by  TrojanRabbit  Posted    (Edited  )
To reference a control by variable:
Me.Controls(var)
or
Form_frmName.Controls(var)
Control properties may be used with this reference also (Me.Controls(var).Name).

You can use a similar method for referring to a form or report by variable.
CurrentProject.AllForms(var).Name
CurrentProject.AllReports(var).Name

Forms(var) and Reports(var) refer to currently open forms or reports respectively.

Note that var can be an integer (index variable) or a string (name).
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top