I have a function whereby I am trying to create an insert into statement by saving the column names from a select and using that output to write the insert into. So I try to create a 2- dimensional array filling the first slot with the areas (651,652 and 801) and the 2nd slot with the column name, which I can get from a select.
So my function starts like this:
Function create_insert() as boolean
Dim arrCol(0 to 2,0 to 75) as variant
Dim A(0 to 2) as variant
A(0) = "651"
A(1) = "652"
A(2) = "801"
Set dbs=currentdb()
For i = lbound(A) to 2
Set rs= dbs.openrecordset("select...". & A(i))
Do while not rs.eof
ArrCol(i, 1) = A(i)
ArrCol(i, i+j) = rs(0).Value
J=j +1
rs.movenext
Loop
Next i
But I'm having problems with the dimensions of the array.
Because it's 3 tables (areas) that I'm getting the columns from I need to both information the table and column..
What am I doing wrong?
So my function starts like this:
Function create_insert() as boolean
Dim arrCol(0 to 2,0 to 75) as variant
Dim A(0 to 2) as variant
A(0) = "651"
A(1) = "652"
A(2) = "801"
Set dbs=currentdb()
For i = lbound(A) to 2
Set rs= dbs.openrecordset("select...". & A(i))
Do while not rs.eof
ArrCol(i, 1) = A(i)
ArrCol(i, i+j) = rs(0).Value
J=j +1
rs.movenext
Loop
Next i
But I'm having problems with the dimensions of the array.
Because it's 3 tables (areas) that I'm getting the columns from I need to both information the table and column..
What am I doing wrong?
Last edited: