Making Variable Names with Variables

J

Jim

Hello:

I have an Access database with a table with sequentially numbered
fields (e.g., Q10_1, Q10_2, Q10_3, etc.

What I want to do is cycle through the variables to set them to
values. What I want to do is
___________________________________________
For MaxVariables = 1 To 11 Step 1

SubString1 = "rst!Q10_" + CStr(MaxVariables)
MsgBox (SubString1)
rst.Edit
Eval(SubString1) = 999
rst.Update



Next MaxVariables
____________________________________________

Unfortunately, the Eval function doesn't do what I want - what I need
is a way to put the variable name IN a variable and use it. I'm sure
there's a way to do this, but I just can't find it.

Any help appreciated!

Jim
 
G

Guest

Hi Jim,

I think you are really close. Can you replace the + with "&"? the line
should be:

SubString1 = "rst!Q10_" & CStr(MaxVariables)

chun
 
J

John Spencer

Perhaps you want

rst.Fields("q10_" & MaxVariables) = 999



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top