I have a long series of global variable names where the last character is a number.
Example:
MyVariableName1,
MyVariableName2,
MyVariableName3, etc.
I am trying to cycle through this long series using a loop and then read the value of each variable.
The error message is:
“Microsoft Access can’t find the name ‘MyVariableName1’ you enter in the expression.”
The error type number is:
“2482”
May goal is to have strTempVariableName read not a text but the value of the variable that this name represents.
The global variables are properly declared and work fine in other areas of the code, so I know that part is working.
Any help on this line of code, or a better way to do this would be helpful.
Thanks for reading.
Example:
MyVariableName1,
MyVariableName2,
MyVariableName3, etc.
I am trying to cycle through this long series using a loop and then read the value of each variable.
Code:
Dim intLoopCounter As Integer
Dim strTempVariableName As String
Dim strTempValue As String
intLoopCounter = 1
Do Until intLoopCounter > 500
strTempVariableName = _
“MyVariableName” & intLoopCounter
‘***NOTE: Code error is on this next line***
strTempValue = eval(strTempVariableName)
‘ code here uses strTempValue
intLoopCounter = intLoopCounter +1
Loop
The error message is:
“Microsoft Access can’t find the name ‘MyVariableName1’ you enter in the expression.”
The error type number is:
“2482”
May goal is to have strTempVariableName read not a text but the value of the variable that this name represents.
The global variables are properly declared and work fine in other areas of the code, so I know that part is working.
Any help on this line of code, or a better way to do this would be helpful.
Thanks for reading.