423,350 Members | 2,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,350 IT Pros & Developers. It's quick & easy.

in DAO: Run time error 3061 Too few parameters....

P: n/a
I wonder what I'm missing?

I really feel like a retard because I've been screwing with some code for a
very long time. I just must be missing something very simple.
In the following example, I've stripped away everything that doesn't cause
the error to make my question a little simpler.

Here's the problem in its simplest form inside a report:

Dim db As DAO.Database
Dim rs As DAO.RecordSet

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM qryTableOfGrades")

'where qryTableOfGrades is a saved crosstab query.

I get "Run time error 3061 Too few parameters. Expected 0."

but if I just make that last line:

Set rs = db.OpenRecordset("qryTableOfGrades")

I get "Run time error 3061 Too few parameters. Expected 1."

And if I do this:
Set rs = db.OpenRecordset(qryTableOfGrades) ' without quotes

I get "variable not defined."

If I run the query by itself without the report it runs fine.

Jun 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
There is a name in qryTableOfGrades that Access cannot resolve to a field
name, so it interprets it as a parameter.

The parameter could be several things, e.g.:
a) Something like this:
[Forms].[Form1].[Text22]
When you run the query, the Expression Service handles that reference. But
the ES is not available in DAO code, so it is treated as an unsupplied
parameter.

b) A misspelled field name.

c) A field name in the Filter or Order By properties of the query, if the
field no longer exists.

You should be able to identify what the parameter is by closing all forms,
running the query, and seeing what name it asks for.

It is possible to supply the parameter programmatically, e.g.:
Dim qdf As DAO.QueryDef
Set qdf = dbEngine(0)(0).QueryDef("qryTableOfGrades")
qdf.Parameters("[Forms].[Form1].[Text22]") = [Forms].[Form1].[Text22]
Set rs = qdf.OpenRecordset(...

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Richard Hollenbeck" <ri****************@verizon.netwrote in message
news:6ITai.191$cx4.168@trnddc07...
>I wonder what I'm missing?

I really feel like a retard because I've been screwing with some code for
a very long time. I just must be missing something very simple.
In the following example, I've stripped away everything that doesn't cause
the error to make my question a little simpler.

Here's the problem in its simplest form inside a report:

Dim db As DAO.Database
Dim rs As DAO.RecordSet

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM qryTableOfGrades")

'where qryTableOfGrades is a saved crosstab query.

I get "Run time error 3061 Too few parameters. Expected 0."

but if I just make that last line:

Set rs = db.OpenRecordset("qryTableOfGrades")

I get "Run time error 3061 Too few parameters. Expected 1."

And if I do this:
Set rs = db.OpenRecordset(qryTableOfGrades) ' without quotes

I get "variable not defined."

If I run the query by itself without the report it runs fine.
Jun 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.