Include variable in contol reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I use variables while referencing controls? I am using the following
and it is not working, Access isn't recognizing my variables as control
references.

strCheck = Forms!myForm!Check & strVar
strText = "Forms!myForm!Text" & strVar & ".Enabled"
strCombo = "Forms!myForm!Combo" & strVar & ".Enabled"
 
This kind of thing should do it:
Dim strName as String
strName = "Check" & strVar
Debug.Print Forms!myForm.Controls(strName)

Similary you can refer to a form name like this:
Forms("Form1")
 
Back
Top