Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass input

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
lets say I have the query:

Code:
SELECT *
FROM tblSample
WHERE tblSample.date Between [Begin Date] And [End Date];

when a user runs the query i want them to be prompted for the dates, which works.

question - Can i call this query from VBA and pass in values for these so that the vba is not prompted for the dates?
 
Have a look here:
faq701-6763

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Assuming that you have the SQL stored as a query then
Code:
Dim db  As DAO.Database
Dim rs  As DAO.Recordset
Dim Qry As DAO.QueryDef

Set db = Currentdb()
Set Qry = db.QueryDefs("QueryName")

[COLOR=black cyan]' Set the date ranges you want here[/color]
Qry("Begin Date") = DateAdd("M", -1, Date())
Qry("End Date") = Date()

Set rs = Qry.OpenRecordset(dbOpenDynaset)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top