How do you set the parameters for a query you are calling in vba code?
Right now I have this statement:
sql = "q_PMACWeeklyReport"
Set db = CurrentDb
Set Qd = db.QueryDefs("q_PMACWeeklyReport")
Qd.Parameters(WeeklyReportID).Value = RptID
This references a query built in Access - q_PMACWeeklyReport
The field I want to sort by - WeeklyReportID
And the public function I use to get the data to sort WeeklyReportID - RptID
This is the code for the function:
Dim f_Reports As Form
Set f_Reports = Forms!f_Reports
RptID = Forms!f_Reports!cmbReportDate.Column(0)
The function picks the data up just fine. It is the QD parameters statement that isn't working right at all. Am I using it wrong? Even when I plug the data directly into the statement (using 27 rather than RptID), I get errors.
How do I make this work?