I am attempting to create the recordset. But I get a Runtime error 3061, Too few parameters. Expected 3
If I replace the tempVars in my query, with a regular parameter, say replace [tempVars]![CalendarID] with 1 and replace the tempVars fort year start and end with dates, everything works as expected.
Any guidance would be greatly appreciated.
This is the recordset:
strSQL = "SELECT RequestDate, AvailableSlots " & _
"FROM qry_FilteredSlots GROUP BY RequestDate, AvailableSlots " & _
"HAVING Month([RequestDate]) = " & intMonth
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then rst.MoveFirst
This is the query:
SELECT qry_Quota_Assignments_ByDate.Dates AS RequestDate, qry_Filtered_RequestCount.CountOfRequestID, qry_Quota_Assignments_ByDate.Quota AS Slots, qry_Quota_Assignments_ByDate.CalendarID, IIf([CountOfRequestID]>=[Slots],0,1) AS AvailableSlots
FROM qry_Filtered_RequestCount INNER JOIN qry_Quota_Assignments_ByDate ON qry_Filtered_RequestCount.RequestDate = qry_Quota_Assignments_ByDate.Dates
GROUP BY qry_Quota_Assignments_ByDate.Dates, qry_Filtered_RequestCount.CountOfRequestID, qry_Quota_Assignments_ByDate.Quota, qry_Quota_Assignments_ByDate.CalendarID
HAVING (((qry_Quota_Assignments_ByDate.Dates) Between [tempVars]![YearStart] And [tempVars]![YearEnd]) AND ((qry_Quota_Assignments_ByDate.CalendarID)=[tempVars]![CalendarID]));