I can't figure out if this is possible in Access. I am getting Run-time error 2482 can't find the name "test1" you entered in the expression.
I am sending 2 arrays to a function that executes an SQL INSERT procedure. One array contains the table field names and the other the data. If I could have an associative array, I wouldn't have a problem. But since I don't, I have to make sure the data is in the correct spot in the array.
Since I have to match the field names to the data, I would like to do:
The problem comes in that throughout the procedure, I need to execute the SQL insert procedure multiple times and the tmpX data is changing. So currently I just reexecute the arrData = array() line. But this gets messy and tricky when you have 20 variables that are changing frequently during development.
So I want one place to tell it what the variable names are, but not actually evaluate the variables until I've assigned them.
Is there some function that I'm not thinking of - or some way to use Eval in this context?
/Wendy
I am sending 2 arrays to a function that executes an SQL INSERT procedure. One array contains the table field names and the other the data. If I could have an associative array, I wouldn't have a problem. But since I don't, I have to make sure the data is in the correct spot in the array.
Since I have to match the field names to the data, I would like to do:
Code:
arrFields = array("field1", "field2")
arrData = array(tmp1, tmp2)
The problem comes in that throughout the procedure, I need to execute the SQL insert procedure multiple times and the tmpX data is changing. So currently I just reexecute the arrData = array() line. But this gets messy and tricky when you have 20 variables that are changing frequently during development.
So I want one place to tell it what the variable names are, but not actually evaluate the variables until I've assigned them.
Code:
Public Function test()
Dim arrData As Variant
Dim arrVariables As String
arrVariables = "test1, test2, test3"
Dim test1 As String
Dim test2 As String
Dim test3 As String
test1 = "Hello"
test2 = "I"
test3 = "did it"
arrData = Array(Eval(arrVariables))
Dim i As Integer
For i = 0 To UBound(arrData)
Debug.Print arrData(i)
Next
End Function
Is there some function that I'm not thinking of - or some way to use Eval in this context?
/Wendy