Too Few Parameters

DazedandMuddled

is not hard? is it......?
Local time
Today, 16:42
Joined
Apr 9, 2004
Messages
11
Too few parameters?!?

Can anyone check this code and tell me where i've gone wrong....please!

VBA code is:

code:---------------------------------------------------------------------
Private Sub ConfirmBooking_Click()
Dim DB As DAO.Database
Dim rst As DAO.Recordset

Set DB = CurrentDb()
Set rst = DB.OpenRecordset("qryBooking")

If rst.BOF And rst.EOF Then
Call MsgBox("Your booking is confirmed", vbExclamation, "Booking Confirmed")
DoCmd.GoToRecord , , acNewRec
Else
rst.MoveFirst
Do Until rst.EOF
If rst.RecordCount > 0 Then
Call MsgBox("Sorry this aircraft is already booked, please choose another time", vbCritical, "Error")
End If
rst.MoveNext
Loop
End If
End Sub
-------------------------------------------------------------------------


and the SQL query code is:

code:---------------------------------------------------------------------
SELECT BookingDetails.AcReg, BookingDetails.HireDate, BookingDetails.StartTime, BookingDetails.EndTime,
FROM BookingDetails
WHERE (((BookingDetails.AcReg)=Forms!BookingForm!cboAcReg)
And
((BookingDetails.HireDate)=Forms!BookingForm!cboHireDate)
And
((BookingDetails.StartTime) Between forms!bookingform!cboStarttime And Forms!BookingForm!cboEndTime)
Or (((BookingDetails.AcReg)=Forms!BookingForm!cboAcReg)
And ((BookingDetails.HireDate)=Forms!BookingForm!cboHireDate)
And ((BookingDetails.EndTime) Between forms!bookingform!cboStarttime And Forms!BookingForm!cboEndTime) ;
--------------------------------------------------------------------------
the error message i get is runtime error 3061, too few parameters: expected 4

i can't figure out why

this code runs from a button on my form which contains all the above fields as combo boxes!

Any pointers anyone?

TIA
Cam
 
When you open a recordset using the DAO method you can't simply open a query with parameters if you don't supply the parameters.

In your case you have built an SQL string with the following four parameters but no value supplied with them:

Forms!BookingForm!cboAcReg
Forms!BookingForm!cboHireDate
Forms!bookingform!cboStarttime
Forms!BookingForm!cboEndTime

The way around this is to use a QueryDef object. This thread demonstrates this...
 
Mile-O-Phile said:
When you open a recordset using the DAO method you can't simply open a query with parameters if you don't supply the parameters.

In your case you have built an SQL string with the following four parameters but no value supplied with them:



The way around this is to use a QueryDef object. This thread demonstrates this...

thanks for the pointers - got it to work

so if anybody's looking for a booking database........
 
DazedandMuddled said:
so if anybody's looking for a booking database........
Put it on the sample databases thread then

Col
 

Users who are viewing this thread

Back
Top Bottom