Too few parameters, Expected 1 (1 Viewer)

haorit1

New member
Local time
Today, 16:42
Joined
Jun 15, 2011
Messages
7
SOS. Please help!

i have a very simple thing that i'm trying to do.


Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT Count(*) FROM Flights where Flights.Plane_ID.Value = '" & Me!Plane_ID.Value & "'")


rs.Close
Set rs = Nothing

but i'm getting the error: run time error 3061. Too few parameters. Expected 1

what can i do?
 

boblarson

Smeghead
Local time
Today, 07:42
Joined
Jan 12, 2001
Messages
32,059
Is Plane_ID numeric or text? If numeric, leave off the single quotes:

Set rs = CurrentDb.OpenRecordset("SELECT Count(*) FROM Flights where Flights.Plane_ID.Value = " & Me!Plane_ID)

But quick question - is Flights.Plane_ID a multivalued field?
 

haorit1

New member
Local time
Today, 16:42
Joined
Jun 15, 2011
Messages
7
thank you for your reply.

Plane_ID is numeric. its a lookup field.

what do you mean by "multivalued field"? is it the definition of lookup where "allow multiple values" = yes\no ?
if so, its a "no".
 

boblarson

Smeghead
Local time
Today, 07:42
Joined
Jan 12, 2001
Messages
32,059
If it isn't a lookup field then you would need to modify to this:

Set rs = CurrentDb.OpenRecordset("SELECT Count(*) FROM Flights where Flights.Plane_ID = " & Me!Plane_ID)

The field in the table then, if it isn't a multi-valued field (see here for what that means) then you wouldn't have .Value on it.
 

haorit1

New member
Local time
Today, 16:42
Joined
Jun 15, 2011
Messages
7
i've been trying to solve this for 5 hours. and now you solved it for me in 10 minutes.

thank you so much!!!!
 

theKruser

Registered User.
Local time
Today, 10:42
Joined
Aug 6, 2008
Messages
122
I am having a similar issue with the following code:

Code:
Dim dbsManager As DAO.Database
Dim rstInfo As DAO.Recordset
 
Set dbsmanager = CurrentDb
Set rstInfo = dbsManager.OpenRecordset("qryInfo", dbOpenDynaset)

I am getting the "Too few parameters. Expected 1." error as well. I have checked the query referenced and it is working fine. I am lost. any help would be greatly appreciated.
 

theKruser

Registered User.
Local time
Today, 10:42
Joined
Aug 6, 2008
Messages
122
Thanks for the reply!

Question: would the code/precess be different in a split db? I have tried the info from the link you included, but still can't get it to work.

Thanks again for your help!
 

Users who are viewing this thread

Top Bottom