How to call a parameter query with parameters in code?

  • Thread starter Thread starter Guest
  • Start date Start date
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
--
 
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,
 
Back
Top