Populate from Array

  • Thread starter Thread starter Albert
  • Start date Start date
A

Albert

Does anybody knows the easiest way to populate a table
from an array.

In a form I define an array 300 x 4
DIM vArray(300,4) as Double

Then in the code a assigned values to it.
I want to see the results in a table.
Is there a way to Append From Array to a table?
 
Dim lngRow as long
Dim lngCol as long

For lngRow = 0 to Ubound(vArray, 2)
CurrentProject.Connection.Execute "INSERT INTO YourTable(Field1, Field2,
Field3, Field4)" _
& " VALUES(" & vArray(0, lngRow) & "," & vArray(1, lngRow) & "," &
vArray(2, lngRow) & "," & vArray(3, lngRow) & ")"
Next lngRow

Note: this air code, you may need to adjust the Ubound to reflect the proper
boundary. All values are numeric, soyou don't need to enclose any inserted
data in quotes ...
 
Back
Top