Hello all really struggling here to get this to work, I need to update a config table, there are 2 arrays array 1 "ImportTableHeaderFields" Single dimension which is basically the field names of the table and Array 2 is "ImportConfig " a 2 Dimensional array of the configuration data Description and Serial number
the Array structure looks like this
Array Name Value
ImportTableHeaderFields(0) = Date
ImportTableHeaderFields(1) = Electronics Sect
ImportTableHeaderFields(2) = APU
ImportTableHeaderFields(3) = SPU
ImportTableHeaderFields(4) = memory
ImportConfig(0,0) = APU
ImportConfig(0,1) = MPU
ImportConfig(0,2) = CPU
ImportConfig(1,0) = Serial Numbers 1005
ImportConfig(1,1) = Serial Numbers 22325
ImportConfig(1,2) = Serial Numbers 5524Z
My code so far gets me all the values i need in both arrays
Any help would be appreciated
the Array structure looks like this
Array Name Value
ImportTableHeaderFields(0) = Date
ImportTableHeaderFields(1) = Electronics Sect
ImportTableHeaderFields(2) = APU
ImportTableHeaderFields(3) = SPU
ImportTableHeaderFields(4) = memory
ImportConfig(0,0) = APU
ImportConfig(0,1) = MPU
ImportConfig(0,2) = CPU
ImportConfig(1,0) = Serial Numbers 1005
ImportConfig(1,1) = Serial Numbers 22325
ImportConfig(1,2) = Serial Numbers 5524Z
My code so far gets me all the values i need in both arrays
Code:
Sub RowsArray2()
Dim dbs As Database, rst As Recordset, rs2 As DAO.Recordset, StrSql As String
Dim ImportTableHeaderFields, ImportConfig As Variant
StrSql = "SELECT * FROM Product" ' Build SQL statement that returns specified fields.
Set dbs = CurrentDb
Set rst = CurrentDb.OpenRecordset("Import")
'List Import Table column Names in the Array
ReDim ImportTableHeaderFields(rst.Fields.Count - 1)
Dim lngCount As Long
For lngCount = 0 To rst.Fields.Count - 1
ImportTableHeaderFields(lngCount) = rst.Fields(lngCount).Name
Next lngCount
Set rst = dbs.OpenRecordset(StrSql)
rst.MoveLast
rst.MoveFirst
ImportConfig = rst.GetRows(rst.RecordCount)
rst.Close
Set dbs = Nothing
End Sub
what i need to do is something like this i think but i cannot get it to insert anything in to the table.
with rs2
.AddNew (when ImportTableHeaderFields = ImportConfig add ImportConfig(1,0).value to new record)
rst![ImportTableHeaderFields] = rs2![ImportConfig].value
.update
Any help would be appreciated
Last edited: