Too few parameters in Query Object

  • Thread starter Thread starter Senthilkumar K T
  • Start date 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
 
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
 
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.
 
Back
Top