Run time error 3061 too few parameters. expected 1

pengiliverpool

New member
Local time
Today, 16:45
Joined
Nov 18, 2009
Messages
8
hi i have a form that takes input from a user and queries a table with that input.
At the moment it takes a start date and end date from a user and thos works fine. i have tried to incorporate a futher paramenter of department from the user and am experiencing an error.

Dim Db As DAO.Database
Dim rstable As DAO.Recordset
Dim Date1 As Date
Dim Date2 As Date
Date1 = Form_Menu.Combo1.Value
Date2 = Form_Menu.Combo2.Value

Set Db = CurrentDb
sResults = "SELECT * FROM Saved_Data WHERE (((Saved_Data.A5)>= #" & Format(Date1, "MM/DD/YYYY") & "# And (Saved_Data.A5) <= #" & Format(Date2, "MM/DD/YYYY") & "# ));"
Set rstable = Db.OpenRecordset(sResults, dbOpenDynaset)

Above is my code that works at the moment.
below is how i tried to incorporate a new parameter "combo156"

sResults = "SELECT * FROM Saved_Data WHERE (((Saved_Data.A4)=[Forms]![Menu]![Combo156]) AND ((Saved_Data.A5)>= #" & Format(Date1, "MM/DD/YYYY") & "# And (Saved_Data.A5) <= #" & Format(Date2, "MM/DD/YYYY") & "# ));"
Set rstable = Db.OpenRecordset(sResults, dbOpenDynaset)

Any Help would be greatly appreciated
 

Users who are viewing this thread

Back
Top Bottom