Question
May 27, 2010 at 03:11 PM
johnhurgeton

How to use a string to reference a variable in VBA

by johnhurgeton . Updated 16 years, 2 months ago

I have a series of variables, MCHandlesOriginal1, MCHandlesOriginal2, and so forth, which I create in a loop. I want to assign each variable a value from a recordset but can’t seem to make it work. Code goes like this:
MyVar=”TextBox”
for i = 1 to 10
NewVar=””
NewVar= MyVar & cstr(i)
NewVar.value = !MyField
next i
I’ve tried using eval(NewVar) to no avail. Any suggestions?

This discussion is locked

All Comments