Too few parameters expected 3

G

Guest

I get the above message when running the following code.
What is the problem?

Dim MyDb As Database, MySet As Recordset
Set MyDb = CurrentDb
Set MySet = MyDb.OpenRecordset("QueryAv")
MySet.Edit
MySet![Booking ID] = lngNext
MySet.Update
MySet.Close
Set MySet = Nothing

Thanks in advance.
 
V

Van T. Dinh

Must be a late start for the School assignment!

"Kate" has been asking about "QueryAv" about a week ago. Search Google for
Tina's answers to Kate's threads (she posted so many threads and I can find
them).

Here is my previous reply wich may / may not apply to your "QueryAv":

There are 3 Parameters that need to be resolved before passing the SQL
String to JET for processing. They are:

Forms![SINGLE BOOKING AVAILABILITY]!BookingDate
Forms![SINGLE BOOKING AVAILABILITY]!Combo8
Forms![SINGLE BOOKING AVAILABILITY]!Combo10

Note that JET Database Engine which process the SQL String does not know
anything about Forms or Controls on Form so these need to be replaced with
actual values before passing the SQL String to JET for processing.
 
J

Joe Fallon

Access can figure out what the parameter is when the query is run in the
grid. Then Access will inform the Jet Engine what it is.

However, when the same query is run in code, you must tell the Jet engine
what the
parameter is yourself.

This is the slickest way to do it:

With queries that contain parameters that are all references to
controls on open forms, you can simulate the expression service that Access
provides when the queries are run through the user interface, as follows:

Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
Dim prm As Parameter

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rs = qdf.OpenRecordset(dbOpenDynaset)
' or qdf.Execute dbFailOnError
 

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

Top