Dim rst As DAO.Recordset
Dim lngNum As Long
Set rst = CurrentDb.Open("TableNameHere")
For 1 to UBound(YourArray)
With rst
.AddNew
!FieldName = YourArray(lngNum)
.Update
End With
lngNum = lngNum + 1
Next
(Air code - not tested, but it should give you a start)
I am trying to write this data to a table (tbltest) that has 7 fields (named 1 through 7 for now).
I am currently trying:
Code:
i = 1
lngNum = 1
Dim rst2 As DAO.Recordset
Set rst2 = CurrentDb.OpenRecordset("test")
For i = 1 To UBound(DataHold())
With rst2
.OpenRecordset
.AddNew
FieldName = DataHold(lngNum, lngNum)
.Update
End With
lngNum = lngNum + 1
Next
This does insert the rows into the table, but does not enter anything. Since this is a multi-dimensional array, I'm not sure how to update from field to field. I used DataHold(lngNum, lngNum) to at least pull one element from the array, but it still didn't write it.
Dim i As Long
Dim rst2 As DAO.Recordset
Set rst2 = CurrentDb.OpenRecordset("test")
For i = 1 To UBound(DataHold())
With rst2
.OpenRecordset
.AddNew
.Field("Field1" = DataHold(i, 1)
.Field("Field2" = DataHold(i, 2)
.Field("Field3" = DataHold(i, 3)
...
.Field("Field7" = DataHold(i, 7)
.Update
End With
Next