How to call a parameter query with parameters in code?

G

Guest

Hi all,

I have a parameter query set up. I would like to call the parameter query
from VBA code and pass the parameters to it. The parametes are StartDate and
EndDate.
Can you share with me how I can accomplish this? Thanks in advance.

Ben
--
 
G

George Nicholson

One approach:

Set db = CurrentDB
Set qdf = db.QueryDefs("MyQuery")
qdf![Please enter a StartDate] = #02/01/2006#
qdf![Please enter an EndDate] = Now()
qdf.Execute dbFailOnError
qdf.Close
Set qdf = Nothing

"[Please enter a StartDate]", etc., has to match the Parameter phrase(s)
from your query exactly.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top