How to create a variable name from a string
Posted on 2011-03-15
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.
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...
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")