Too few parameters.

grnzbra

Registered User.
Local time
Today, 09:33
Joined
Dec 5, 2001
Messages
376
Please look at this sql statement and tell me where the error is. When I try to open the recordset, I get a "Too few parameters. Expected 1" error. That kind of error usually goes with missing # on dates or ' on text

DateTime is a DateTime field that defaults to Now().

The problem appears to be in the dates because when I comment out all after the user parameter, it works, and taking out the "AND Used Is Null" doesn't help.

sqlstr = "SELECT * " & _
"FROM tbl_Usage " & _
"WHERE User = '" & UsrNm & "' " & _
"AND DateTime >= #" & Date & "# and DateTime < #" & DateAdd("d", Date, 1) & "# AND Used Is Null"

This is from the immediate window
?sqlstr
SELECT * FROM tbl_Usage WHERE User = 's5ucba' AND DateTime >= #9/21/2006# and DateTime < #9/22/2006# AND Used Is Null
 
Warning Warning Warning

Let this be a warning. When something looks like it should be right but isn't, look further. I just found that the problem was that when I copied in a duplicat table from what was being used when I started, the new table's date field was DtTm, not DateTime. It works fine now that I got that right.
 

Users who are viewing this thread

Back
Top Bottom