Reputation: 1609
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.
Upvotes: 3
Views: 10683
Reputation: 1609
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
Upvotes: 8