parameterized query usage
Posted on 2014-03-06
Been using Access for many years but though EE I just recently found out about parameterized queries.
I understand the concept but I'm not sure of the code to invoke the query with the paramaters.
I set up a query 'qryTest_Paramters' that will select data from table 'tblFees' based on the 'dateadded' field.
In the query, as criterion on the date added field I have 'Between [RangeFromDate] And [RangeEndDate].
I then set up RangeFromDate and RangeEndDate as parameters with a type of Date/Time.
When I run the query manually it prompts me to enter RangeFromDate and RangeEndDate and the resultant query shows the records based on the filter.
Now I want to invoke this query form VBA code behind a form. The user enters two fields on the form BeginDate and EndDate.
In this case I want to create an export of the filtered data form the query.
Currently I have a transferspreadsheet command that exports the entire file, not just the filtered records
docmd.transferspreadsheet acexport, acspreadsheettypeExcel8, "qryXXXX", gselectedfolder
I would like to change "qryxxx" in that statement to export only filtered data from query 'qryTest_Paramter'
What is the syntax for using the parameterized query?