Hello,
I am having issues with a VBA recordset:
The long piece of code relating to the date is required as my listbox, which is fed by a calendar control, stores the dates as strings rather than dates.
The problem I am having is with the HAVING clause. Using the code above I get "Run-time error '3133': Syntax error in HAVING clause."
I know the date part of the HAVING clause works in a different recordset (the project is a holiday database, I have already used the above date code to check a recordset for duplicate holiday requests, records which already exist with the requested date & name combo) and the HolType code is very simple, I can't see that being wrong.
I cannot see anything wrong with the SQL which I have used...
Any help would be greatly appreciated.
I am having issues with a VBA recordset:
Code:
Set r = db.OpenRecordset("SELECT tblHolidays.DateBooked, sum(tblHolidays.TotalHours) AS SumOfTotalHours " & _
"FROM (tblHolidays INNER JOIN tblStaff ON tblStaff.Name = tblHolidays.Name) " & _
"HAVING tblHolidays.DateBooked = #" & Format(DateSerial(Right(lstDates.ItemData(i), 4), Mid(lstDates.ItemData(i), 4, 2), Left(lstDates.ItemData(i), 2)), "mm\/dd\/yyyy") & "# " & _
"AND tblStaff.HolType = '" & Forms!frmSelectAgent!cboTeam & "' " & _
"GROUP BY tblHolidays.DateBooked")
The long piece of code relating to the date is required as my listbox, which is fed by a calendar control, stores the dates as strings rather than dates.
The problem I am having is with the HAVING clause. Using the code above I get "Run-time error '3133': Syntax error in HAVING clause."
I know the date part of the HAVING clause works in a different recordset (the project is a holiday database, I have already used the above date code to check a recordset for duplicate holiday requests, records which already exist with the requested date & name combo) and the HolType code is very simple, I can't see that being wrong.
I cannot see anything wrong with the SQL which I have used...
Any help would be greatly appreciated.
