Ahhhh, why is this so difficult!!
I'm sure there is an easy answer but I am somehow missing it. When I try to add the array I need to a table it adds in diagonally, i.e. instead of placing 200 records in one row of the record set it places each one in a new column but 1 row below the last.
This is the code I am using:
Code:
Call openConnection
cn.Open strConnection
Set rs = New ADODB.Recordset
rs.Open "tblNL1Dash", cn, adOpenKeyset, adLockOptimistic
For i = LBound(DashArray) To UBound(DashArray)
With rs
.AddNew
.Fields(i) = DashArray(i)
.update
End With
Next i
Call closeConnection
I also tried to write the array to a worksheet and then read it into the Access table using this code with the same result:
Code:
Set WriteRng = NDM.Range("NDM_tblNL1Dash").offset(1, 0).Resize(1, DashCtr)
WriteRng = DashArray
Call openConnection
cn.Open strConnection
Set rs = New ADODB.Recordset
rs.Open "tblNL1Dash", cn, adOpenKeyset, adLockOptimistic
For i = LBound(DashArray) To UBound(DashArray)
With rs
.AddNew
.Fields(i) = NDM.Range("NDM_tblNL1Dash").offset(1, i - 1)
.update
End With
Next i
Call closeConnection
I simply want the data written into on new record set into the table. Any ideas???
Also in the sites that Gicu provided above I found this code:
Code:
rs.AddNew Array(Field1,Field2), Array(Value1,Value2)
and tried to add the array directly using:
Code:
Call openConnection
cn.Open strConnection
Set rs = New ADODB.Recordset
rs.Open "tblNL1Dash", cn, adOpenKeyset, adLockOptimistic
rs.AddNew DashArray
rs.update
Call closeConnection
This would be my preferred solution however I get an error "Arguments are of the wrong type ......."
Any ideas on how to make this option work.
Kind regards,
Marcus