Too few parameters?

L

Leif

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.
 
J

John Nurick

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.
 
S

Steve Sanford

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
 

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