T
TheGMan
Guest
How do I refer to a form control using a variable?
1... FORM2 is opened by FORM1 (which stays active in the background)
2... In FORM2, the user makes a selection which defines the value for another control in FORM1. It may be any of 10 FORM1 controls, depending upon the user selection.
3... I'd like to have code that checks the user selection and builds the control name into a variable and then executes a standard routine for that variable.
Right now I have:
DoCmd.SelectObject acForm, "FORM1"
Forms![FORM1]![CustomerAttribute01] = "Some Value"
But I am referring to a specific control in FORM1.
I'm trying to achieve something like:
Dim vControlName as Field
vControlName = "CustomerAttribute01"
DoCmd.SelectObject acForm, "FORM1"
Forms![FORM1]!vControlName= "Some Value"
Which obviously isn't going to work.
Any help would be greatly appreciated!
Thanks
Gary
1... FORM2 is opened by FORM1 (which stays active in the background)
2... In FORM2, the user makes a selection which defines the value for another control in FORM1. It may be any of 10 FORM1 controls, depending upon the user selection.
3... I'd like to have code that checks the user selection and builds the control name into a variable and then executes a standard routine for that variable.
Right now I have:
DoCmd.SelectObject acForm, "FORM1"
Forms![FORM1]![CustomerAttribute01] = "Some Value"
But I am referring to a specific control in FORM1.
I'm trying to achieve something like:
Dim vControlName as Field
vControlName = "CustomerAttribute01"
DoCmd.SelectObject acForm, "FORM1"
Forms![FORM1]!vControlName= "Some Value"
Which obviously isn't going to work.
Any help would be greatly appreciated!
Thanks
Gary