Hi,
I am opening recordset that performs well until I set some criteria in the underlying query.
This is my query and VBA code that work:
The moment I change my query to include a filter, the form gives an error message "Too Few Parameters expected 1". (Query opens to give required results). VBA code is in the ON-OPEN property of the form.
I feel that critera has to be set when opening the recordset rather than in the underlying query, but I'm not sure how to do that. :)
I am opening recordset that performs well until I set some criteria in the underlying query.
This is my query and VBA code that work:
Code:
SELECT Booking.BookingID, Booking.BookingDate, Booking.BookingTime, Booking.EstimateTime, ACC_Vehicle.Reg, Staff.StaffName, Booking.MechanicID FROM (Booking INNER JOIN ACC_Vehicle ON Booking.ACCVehicleID = ACC_Vehicle.ACCVehicleID) INNER JOIN Staff ON Booking.MechanicID = Staff.StaffID;
Code:
'set array
Dim TimeSlot(9, 3) As Long 'Define Array
Dim TimeReg(9) As String ' array for vehicle reg
Dim NoofBookings As Integer, A As Integer 'Set Counters
Dim lngHours As Long, lngMins As Long 'Seperate Hours Mins of Booking Time
Dim lngDurHours As Long, lngDurMins As Long ' Seperate Hours and Mins of Duration
Dim LeftPos As Long, tw As Long 'Define StartPosition for Chart
'Configure Datbase and RecordSet
Dim rs As Recordset
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Booking_TimeGraph", dbOpenDynaset)
'Count no. of bookings
rs.MoveFirst
rs.MoveLast
NoofBookings = rs.RecordCount
I feel that critera has to be set when opening the recordset rather than in the underlying query, but I'm not sure how to do that. :)
Code:
SELECT Booking.BookingID, Booking.BookingDate, Booking.BookingTime, Booking.EstimateTime, ACC_Vehicle.Reg, Staff.StaffName, Booking.MechanicID FROM (Booking INNER JOIN ACC_Vehicle ON Booking.ACCVehicleID = ACC_Vehicle.ACCVehicleID) INNER JOIN Staff ON Booking.MechanicID = Staff.StaffID WHERE (((Booking.MechanicID)=[Forms]![Bookings]![MechanicID]));
Comment