G
Guest
I have 41 tables. I would like to append the data in them to one table. I
don't work with arrays much, but would like to get around writing tons of
queries. Can someone take a look at this and tell me what I am doing wrong?
Public Sub FillArrayandAppend()
covs(0) = "COV000 MTD Application Summaryb"
covs(1) = "COV001 MTD Application Summaryb"
covs(2) = "COV002 MTD Application Summaryb"
covs(3) = "COV003 MTD Application Summaryb"
covs(4) = "COV004 MTD Application Summaryb"
covs(5) = "COV005 MTD Application Summaryb"
covs(6) = "COV006 MTD Application Summaryb"
covs(7) = "COV099 MTD Application Summaryb"
covs(8) = "COV100 MTD Application Summary"
covs(9) = "COV101 MTD Application Summary"
covs(10) = "COV104 MTD Application Summary"
covs(11) = "COV106 MTD Application Summary"
covs(12) = "COV201 MTD Application Summary"
covs(13) = "COV202 MTD Application Summary"
covs(14) = "COV211 MTD Application Summary"
covs(15) = "COV213 MTD Application Summary"
covs(16) = "COV301 MTD Application Summary"
covs(17) = "COV302 MTD Application Summary"
covs(18) = "COV303 MTD Application Summary"
covs(19) = "COV304 MTD Application Summary"
covs(20) = "COV600 MTD Application Summary"
covs(21) = "COV610 MTD Application Summary"
covs(22) = "COV611 MTD Application Summary"
covs(23) = "COV613 MTD Application Summary"
covs(24) = "COV614 MTD Application Summary"
covs(25) = "COV615 MTD Application Summary"
covs(26) = "COV617 MTD Application Summary"
covs(27) = "COV700 MTD Application Summary"
covs(28) = "COV701 MTD Application Summary"
covs(29) = "COV702 MTD Application Summary"
covs(30) = "COV703 MTD Application Summary"
covs(31) = "COV708 MTD Application Summary"
covs(32) = "COV709 MTD Application Summary"
covs(33) = "COV710 MTD Application Summary"
covs(34) = "COV798 MTD Application Summary"
covs(35) = "COV799 MTD Application Summary"
covs(36) = "COV801 MTD Application Summary"
covs(37) = "COV803 MTD Application Summary"
covs(38) = "COV804 MTD Application Summary"
covs(39) = "COV805 MTD Application Summary"
covs(40) = "COV990 MTD Application Summary"
covs(41) = "COV992 MTD Application Summary"
For x = 0 To 41
Dim db As DAO.Database
Dim rst As DAO.Recordset
strtable = covs(x)
Set db = CurrentDb
sqlstatement = "Select * From [" & strtable & "]"
Set rst = db.OpenRecordset(sqlstatement)
ssql = "INSERT INTO MonthlyDetail ( [Item Code], [Item Description],
Units, Price, Extension, AppCode, DateOfFile ) SELECT rst.F1, rst.F2, rst.F3,
rst.F4, rst.F5, Left(rst,6) AS AppCode, [Date of File] AS DateOfFile FROM rst
WHERE rst.F5 Is Not Null;"
DoCmd.RunSQL ssql
Set rst = Nothing
Set db = Nothing
Next
End Sub
don't work with arrays much, but would like to get around writing tons of
queries. Can someone take a look at this and tell me what I am doing wrong?
Public Sub FillArrayandAppend()
covs(0) = "COV000 MTD Application Summaryb"
covs(1) = "COV001 MTD Application Summaryb"
covs(2) = "COV002 MTD Application Summaryb"
covs(3) = "COV003 MTD Application Summaryb"
covs(4) = "COV004 MTD Application Summaryb"
covs(5) = "COV005 MTD Application Summaryb"
covs(6) = "COV006 MTD Application Summaryb"
covs(7) = "COV099 MTD Application Summaryb"
covs(8) = "COV100 MTD Application Summary"
covs(9) = "COV101 MTD Application Summary"
covs(10) = "COV104 MTD Application Summary"
covs(11) = "COV106 MTD Application Summary"
covs(12) = "COV201 MTD Application Summary"
covs(13) = "COV202 MTD Application Summary"
covs(14) = "COV211 MTD Application Summary"
covs(15) = "COV213 MTD Application Summary"
covs(16) = "COV301 MTD Application Summary"
covs(17) = "COV302 MTD Application Summary"
covs(18) = "COV303 MTD Application Summary"
covs(19) = "COV304 MTD Application Summary"
covs(20) = "COV600 MTD Application Summary"
covs(21) = "COV610 MTD Application Summary"
covs(22) = "COV611 MTD Application Summary"
covs(23) = "COV613 MTD Application Summary"
covs(24) = "COV614 MTD Application Summary"
covs(25) = "COV615 MTD Application Summary"
covs(26) = "COV617 MTD Application Summary"
covs(27) = "COV700 MTD Application Summary"
covs(28) = "COV701 MTD Application Summary"
covs(29) = "COV702 MTD Application Summary"
covs(30) = "COV703 MTD Application Summary"
covs(31) = "COV708 MTD Application Summary"
covs(32) = "COV709 MTD Application Summary"
covs(33) = "COV710 MTD Application Summary"
covs(34) = "COV798 MTD Application Summary"
covs(35) = "COV799 MTD Application Summary"
covs(36) = "COV801 MTD Application Summary"
covs(37) = "COV803 MTD Application Summary"
covs(38) = "COV804 MTD Application Summary"
covs(39) = "COV805 MTD Application Summary"
covs(40) = "COV990 MTD Application Summary"
covs(41) = "COV992 MTD Application Summary"
For x = 0 To 41
Dim db As DAO.Database
Dim rst As DAO.Recordset
strtable = covs(x)
Set db = CurrentDb
sqlstatement = "Select * From [" & strtable & "]"
Set rst = db.OpenRecordset(sqlstatement)
ssql = "INSERT INTO MonthlyDetail ( [Item Code], [Item Description],
Units, Price, Extension, AppCode, DateOfFile ) SELECT rst.F1, rst.F2, rst.F3,
rst.F4, rst.F5, Left(rst,6) AS AppCode, [Date of File] AS DateOfFile FROM rst
WHERE rst.F5 Is Not Null;"
DoCmd.RunSQL ssql
Set rst = Nothing
Set db = Nothing
Next
End Sub