
Expanding a variable or referencing a field within variable
How does one expand or refer to another variable within
another variable? In dBase parlance it is called macro-
expansion. Before run-time the variable being referenced
is not known. Only at run-time does the varible become
identified and therefore must be expanded. Here is a
trivial example; listing a group of fields within a
table. There are nine fields within the table; week1,
week2. . .week9. I want to refer to each one. I do not
want to "hard code" this but use a loop and refer to each
field:
For i_loop = 1 To 9
str_fieldname = "rst!week" & Trim(Str(i_loop))
Debug.Print str_fieldname
Next
I do NOT want the concatinated string to print. I want
the CONTENTS of the field within the record set to print.
Do I have to add extra quotes in the second or third line
of code? In dBase you use an operator "&" to expand the
varible i.e. Debug.Print &str_fieldname. Moreover, what
do they call this in Access?
Thanks for the help,
Terry