David_W_R
asked on
How to create a variable name from a string
I need to create a variable or control name from a string.
For example, I am given a number which is 1, 2, 3, 4 or 5.
If the number is 1, I need to reference the form control named cboWS1.
If the number is 4, I need to reference the from control named cboWS4.
etc.
I could use the Select Case statement for this simple example, but my application utilizes a dozen variables that need to have the selected number included in their names...
cboWS4
cboAG4
cboLT4
etc.
It's simple enough to concatenate the "1" to "cboWS" to create "cboWS1", but how do I use this string to create a statement such as... Variable1 = cboWS1
Something to the effect... Variable1 = CName("cboWS1")
For example, I am given a number which is 1, 2, 3, 4 or 5.
If the number is 1, I need to reference the form control named cboWS1.
If the number is 4, I need to reference the from control named cboWS4.
etc.
I could use the Select Case statement for this simple example, but my application utilizes a dozen variables that need to have the selected number included in their names...
cboWS4
cboAG4
cboLT4
etc.
It's simple enough to concatenate the "1" to "cboWS" to create "cboWS1", but how do I use this string to create a statement such as... Variable1 = cboWS1
Something to the effect... Variable1 = CName("cboWS1")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I haven't used MS Access in literally about a decade. Had to open up Access 2010 and play with it to make sure I was right. ;)
ASKER