Too few parameters in Query Object

  • Thread starter Senthilkumar K T
  • Start date
S

Senthilkumar K T

Hai,
i am using Access 2002. I had done parameterized one query
with form variable.

while i try to open the recordset, it gives an error like

"Too few parameters. Expected 2"

How to solve the problem to open an recordset for that query
 
M

Michel Walsh

Hi,


Try to open the query from the query designer. You should be prompted for 2
parameters, either a field name you type incorrectly, either other typo
error.

Note that you can't use a VBA variable as parameter.


Do you use FORMS!FormName!ControlName syntax?



Vanderghast, Access MVP
 
V

Van T. Dinh

Since you used VBA code to create the Recordset, the Expression Service is
not involved and JET (the default database engine for Access) cannot resolve
the reference(s) to the Control(s) on the Form. In this case JET treats
these references as Parameters (without values assigned) and therefore you
get the error.

You need to resolve the references to the Controls before asking JET/VBA to
create the Recordset. Check Access VB Help on the Parameters Collection of
the QueryDef Object.

Note: the same Query will work fine if you open the Query in the GUI
(resulting in the DatasheetView of the Query) since the Expression Service
resolves the references to the Controls for you.
 

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