Private Sub PopulateStagingTable()
Dim rst1 As New ADODB.Recordset
Dim rst2 As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim intR As Integer 'Row counter - number of records
Dim intC As Integer 'Column counter - number of columns
Dim arrInput() As String
Set cn = CurrentProject.Connection
rst1.Open "Sheet1", cn, adOpenStatic, adLockOptimistic
intR = rst1.RecordCount
intC = rst1.Fields.Count
ReDim arrInput(intR, intC)
Dim x As Integer
Dim y As Integer
For x = 0 To intR - 1
For y = 0 To intC - 1
arrInput(x, y) = Nz(rst1(y), "")
Debug.Print rst1.Fields(y).Name
Next y
rst1.MoveNext
Next x
rst2.Open "tbl2NFStaging", cn, adOpenStatic, adLockOptimistic
Dim intMetric As Integer
Dim intMetricStart As Integer
intMetricStart = 9
intMetric = UBound(arrInput, 2) - 9
'Debug.Print intMetric / 3
Dim z As Integer
Dim j As Integer
Dim i As Integer
Dim u As Integer
u = 10
i = 10
For x = 1 To UBound(arrInput, 1)
For z = 0 To intMetric - 1
rst2.AddNew
rst2(1) = Nz(arrInput(x, 0), " ")
rst2(2) = Nz(arrInput(x, 1), " ")
rst2(3) = Nz(arrInput(x, 2), " ")
rst2(4) = Nz(arrInput(x, 3), " ")
rst2(5) = Nz(arrInput(x, 4), " ")
rst2(6) = Nz(arrInput(x, 5), " ")
rst2(7) = Nz(arrInput(x, 6), " ")
rst2(8) = Nz(arrInput(x, 7), " ")
rst2(9) = Nz(arrInput(x, 8), " ")
rst2.Update
Next z
rst2.MoveNext
Next x
'Cleanup
rst1.Close
Set rst1 = Nothing
cn.Close
Set cn = Nothing
End Sub
|