I have a table which I create in vba. I want to then run a sql and store the results into the table. Here is my code, it looks right to me but nothing gets inserted into the table.
Code:
Set db = CurrentDb()
On Error Resume Next
DoCmd.RunSQL ("DROP TABLE [countPrescriptionPlan]")
DoCmd.RunSQL ("Create TABLE [countPrescriptionPlan]")
Set tb2 = db.TableDefs("countPrescriptionPlan")
countColumnsPres = Array("CountofEmplid", "CountofDepBen", "Emplid", "Dep Ben")
For Each col In countColumnsPres
Set FieldName = tb2.CreateField(col, dbText, 100)
tb2.Fields.Append FieldName
Next col
DoCmd.RunSQL ("selectPresPlan")
DoCmd.RunSQL ("countPresPlan")
insString = "INSERT INTO countPrescriptionPlan (CountofEmplid,CountofDepBen,Emplid,Dep Ben)" _
& "Select CountOfEMPLID, CountOFDEPENDENT_BENEF, EMPLID, DEPENDENT_BENEF" _
& "From countPresPlan"
DoCmd.RunSQL insString