Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too Few Parameters?

Status
Not open for further replies.

M4TT5T3R

Programmer
Apr 19, 2001
11
US
Lo... I get the following error:

=================================================
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
=================================================

On this code:

=================================================
DateTime = DateAdd("h", -5, Now)

rsToday.Open "SELECT Date FROM Messages WHERE ForumID = " & rsForums("ForumID") & " AND DateDiff(d, Date, #" & DateTime & "#) = 0", Conn, adOpenStatic
=================================================

I have no idea what's causing it, can someone offer any help?
 
hi

you have to change:

DateDiff(d, Date, #" & DateTime & "#)

into a field name, you can't use a variable here.

Andy
 
Try to save the SQL statement in a string and then write
rs.open ssql,conn,adopenstatic

if still you get an error try replace adopenstatic with 3

Regards,
Durug
 
thanks guys, after i posted i messed around with the code a little bit. This seems to work:

rsToday.open "SELECT Date FROM Messages WHERE ForumID = " & rsForums("ForumID") & " AND DateDiff('d', #" & DateTime & "#, Date) = 0",Conn,adopenstatic


why, i'll never know :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top