I am using Access 2016.
I used the Query Wizard to create an append query that works correctly. I saved the query with the name pendingAdd_qry.
In an Event Procedure on one of my forms, I want to run that query, pendingAdd_qry.
My code gets an error on the Execute statement and I just can't figure out how to fix it. Here is the code I have in the event:
Dim rowsadded As Long
Set dbs = CurrentDb
CurrentDb.Execute "pendingAdd_qry", dbFailOnError
Set db = Nothing
rowsadded = dbs.RecordsAffected
MsgBox rowsadded
I tried to copy the SQL from the query to a string variable and I get an error on that too. tI doesn't want to pick up the "Select" portion of the append query.
Here is the Sql for the query:
INSERT INTO pending_tbl ( pendingDistrict, pendingDio, pendingBlanksneeded, pendingQuad )
SELECT district_tbl.districtID, district_tbl.districtDio, 4 AS Expr1, [currentyear] AS Expr2
FROM district_tbl
ORDER BY district_tbl.districtName;
currentyear is a global variable.
Any help you can give me is appreciated.
Thanks
I used the Query Wizard to create an append query that works correctly. I saved the query with the name pendingAdd_qry.
In an Event Procedure on one of my forms, I want to run that query, pendingAdd_qry.
My code gets an error on the Execute statement and I just can't figure out how to fix it. Here is the code I have in the event:
Dim rowsadded As Long
Set dbs = CurrentDb
CurrentDb.Execute "pendingAdd_qry", dbFailOnError
Set db = Nothing
rowsadded = dbs.RecordsAffected
MsgBox rowsadded
I tried to copy the SQL from the query to a string variable and I get an error on that too. tI doesn't want to pick up the "Select" portion of the append query.
Here is the Sql for the query:
INSERT INTO pending_tbl ( pendingDistrict, pendingDio, pendingBlanksneeded, pendingQuad )
SELECT district_tbl.districtID, district_tbl.districtDio, 4 AS Expr1, [currentyear] AS Expr2
FROM district_tbl
ORDER BY district_tbl.districtName;
currentyear is a global variable.
Any help you can give me is appreciated.
Thanks