In my Access 2007 database, I've got an append query with parameters in it. How do I call this query from a VBA script?
I realize that I could just generate the query text on the fly in the VBA code, but that's much more awkward.
I got the following to work:
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Set db = CurrentDb
Set qry= db.QueryDefs("NameOfMyStoredQuery")
qry.Parameters(0) = FirstParamValue
qry.Parameters(1) = SecondParamValue
qry.Parameters(2) = ThirdParamValue
qry.Execute
qry.Execute dbFailOnError and add an error hander to your procedure.