RUN TIME ERROR 3061

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
Why do I get this message RUN TIME ERROR 3061; TOO FEW PARAMETERS, EXPECTED 1?

This is the code:

Dim Bookable As Boolean
Dim strSQL As String
strSQL = "SELECT Query1.*, Query1.DateBooked FROM Query1 WHERE
(((Query1.DateBooked)=[forms]![Booking]![DateTB]));"
'For Each record In CurrentDb.OpenRecordset(strSQL)
Dim YahooTest As DAO.Database
Dim RSBooking As DAO.Recordset
Set YahooTest = CurrentDb
Set RSBooking = YahooTest.OpenRecordset(strSQL)
Do While Not RSBooking.EOF
If [Start Time] < StartTime Then
If [End Time] < StartTime Then
Bookable = True
MsgBox "Bookable"
Else
Bookable = False
MsgBox "Unbookable"
End If
End If
Loop

It appears my code stops just before the beginning of my Do While loop.
Please let me know what the mistake is.
 
strSQL = "SELECT Query1.*, Query1.DateBooked FROM Query1 WHERE
(((Query1.DateBooked)=[forms]![Booking]![DateTB]));"

This will return all values in Query1 where DateBooked = "[forms]!
[Booking]![DateTB]" (and not the value in [forms]![Booking]![DateTB]
that you wanted). Try this:

strSQL = "SELECT * FROM Query1 WHERE DateBooked = #" & [forms]!
[Booking]![DateTB] & "#"

Cheers,
Jason Lepack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Do While ignores .eof 1
Run-Time error 3061 3
Run-time error 3061 2
Error 3061 1
Type Mismatch Error: New to access programming 2
Error 3061 2
Excel Export Filtered Form Data To Excel 0
dlookup and dao.recordset 4

Back
Top