too few parameters 5 expected

I

iccsi

I am running a query from my form using DAO.recordset.

It gives me message that too few parameters 5 expected.
I only need provide 2 parameters wen I run the query itself.

are there any possibilities that I provide fewer parameters and 2
parameters needed, but Access needs to receive 5 parameters?

Your informaiton is great appreciated,
 
I

iccsi

A little unclear iccsi.  Post the SQL and maybe we can see what parameters
it's looking for.

Bonniehttp://www.dataplus-svc.com

Thanks for the message,

There are 2 DAO.recordset on the report.
One has 3 parameters and one has 2 parametrs.


I oen the second one after first one close, it seems the second one
ask 5 parameter which includes first 3 paramters.

I provided 3 extra dummy paramter to my second query then works.
It does not make sense, but it seems get right results.

Thanks again for helping,
 
G

Graham Mandeno

Hi iccsi

You cannot use OpenRecordset on a query with parameters, even if all those
parameters are "automatically" resolved from form control names, etc.

This is because the recordset is being opened not by Access, but by DAO
which passes the request directly to the Jet database engine. Jet knows
nothing of Access forms.

If you are opening a recordset on a saved parameter query, you can resolve
the parameters for a QueryDef object before you open the recordset.
Something like this:

Dim db as DAO.Database
Dim rs as DAO.Recordset
Dim qdf as DAO.QueryDef
Dim prm as DAO.Parameter

Set db = CurrentDb
Set qdf = db.QueryDefs("YourQuery")
' resolve references to forms like this:
qdf.Parameters("[Forms]![YourForm]![YourControlName]") =
Forms![YourForm]![YourControlName]
' resolve "interactive" parameters like this:
qdf.Parameters("[Please enter a number:]) = 999
Set rs = qdf.OpenRecordset
 

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