B
Brad
Thanks for taking the time to read my question.
My code stopped working and I'm not sure why.
I have a query with 3 criteria in it. I also have this code. When it gets
to Set qdf, and error pops up saying Too Few Parameters, Expected 3. There
are 3 parameters!
What's going on here?
Thanks for your help,
Brad
Code:
Dim dbs As Database, rst As Recordset, qdf As QueryDef
Set dbs = CurrentDb
Set qdf = dbs.OpenRecordset("qryAddNewBookingPossible")
'qdf.Parameters(0).Value = [Forms]![frmtblBookingAddNew]![tblBookingID]
qdf.Parameters(0).Value = [Forms]![frmtblBookingAddNew]![BookingRoomBooked]
qdf.Parameters(1).Value = [Forms]![frmtblBookingAddNew]![BookingStartDate]
qdf.Parameters(2).Value = [Forms]![frmtblBookingAddNew]![BookingEndDate]
Set rst = qdf.OpenRecordset()
Here's my sql:
SELECT [BookingStartDate]+[BookingStartTime] AS BookingStartDateTime,
[BookingEndDate]+[BookingEndTime] AS BookingEndDateTime,
tblBooking.tblBookingID, tblBooking.BookingRoomBooked,
Max(tblBooking.BookingSlot) AS MaxOfBookingSlot, tblBooking.BookingStartDate,
tblBooking.BookingEndDate
FROM tblBooking
GROUP BY [BookingStartDate]+[BookingStartTime],
[BookingEndDate]+[BookingEndTime], tblBooking.tblBookingID,
tblBooking.BookingRoomBooked, tblBooking.BookingStartDate,
tblBooking.BookingEndDate
HAVING
(((tblBooking.BookingRoomBooked)=[Forms]![frmtblBookingAddNew]![BookingRoomBooked])
AND
((tblBooking.BookingStartDate)>=[Forms]![frmtblBookingAddNew]![BookingStartDate])
AND
((tblBooking.BookingEndDate)<=[Forms]![frmtblBookingAddNew]![BookingEndDate]))
ORDER BY [BookingStartDate]+[BookingStartTime],
[BookingEndDate]+[BookingEndTime];
My code stopped working and I'm not sure why.
I have a query with 3 criteria in it. I also have this code. When it gets
to Set qdf, and error pops up saying Too Few Parameters, Expected 3. There
are 3 parameters!
What's going on here?
Thanks for your help,
Brad
Code:
Dim dbs As Database, rst As Recordset, qdf As QueryDef
Set dbs = CurrentDb
Set qdf = dbs.OpenRecordset("qryAddNewBookingPossible")
'qdf.Parameters(0).Value = [Forms]![frmtblBookingAddNew]![tblBookingID]
qdf.Parameters(0).Value = [Forms]![frmtblBookingAddNew]![BookingRoomBooked]
qdf.Parameters(1).Value = [Forms]![frmtblBookingAddNew]![BookingStartDate]
qdf.Parameters(2).Value = [Forms]![frmtblBookingAddNew]![BookingEndDate]
Set rst = qdf.OpenRecordset()
Here's my sql:
SELECT [BookingStartDate]+[BookingStartTime] AS BookingStartDateTime,
[BookingEndDate]+[BookingEndTime] AS BookingEndDateTime,
tblBooking.tblBookingID, tblBooking.BookingRoomBooked,
Max(tblBooking.BookingSlot) AS MaxOfBookingSlot, tblBooking.BookingStartDate,
tblBooking.BookingEndDate
FROM tblBooking
GROUP BY [BookingStartDate]+[BookingStartTime],
[BookingEndDate]+[BookingEndTime], tblBooking.tblBookingID,
tblBooking.BookingRoomBooked, tblBooking.BookingStartDate,
tblBooking.BookingEndDate
HAVING
(((tblBooking.BookingRoomBooked)=[Forms]![frmtblBookingAddNew]![BookingRoomBooked])
AND
((tblBooking.BookingStartDate)>=[Forms]![frmtblBookingAddNew]![BookingStartDate])
AND
((tblBooking.BookingEndDate)<=[Forms]![frmtblBookingAddNew]![BookingEndDate]))
ORDER BY [BookingStartDate]+[BookingStartTime],
[BookingEndDate]+[BookingEndTime];