Too few parameters?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to open a DAO recordset with the following statement.

Set rst = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)

SQL = "SELECT * FROM qryRptByArea WHERE IsNull(CloseOut)"

The message I'm getting is

Run-time error '3061':

Too few parameters. Expected 2.

Looks like 2 to me. Anyone know why I'm getting this message? If I run the
query it runs OK, and it does have a field called CloseOut.

Thanks.
 
Hi Leif,

This will happen if qryRptByArea is a parameter query. You need to
have your code construct a SQL statemente that includes the actual
parameter values required.
 
Do you have these lines (in this order??)

Dim rst As DAO.Recordset
Dim SQL As String

SQL = "SELECT * FROM qryRptByArea WHERE IsNull(CloseOut)"
Set rst = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)

You might also try:

SQL = "SELECT * FROM qryRptByArea WHERE (CloseOut) IS NULL"

The next thing to try is delete the WHERE clause.

SQL = "SELECT * FROM qryRptByArea"
Set rst = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)


If this runs with no errors, then you have a problem with the field
"CloseOut" in the query "qryRptByArea".

Check the field in the query to see if it is aliased.

HTH
 
Back
Top