Isaac Moses
Isaac Moses

Reputation: 1609

In MS Access VBA, how do I call a stored append query with parameters?

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

Answers (1)

Isaac Moses
Isaac Moses

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

Related Questions