Populate from Array

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?
 
S

Scott McDaniel

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 ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top