There is a name in qryTableOfGrade s 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 programmaticall y, e.g.:
Dim qdf As DAO.QueryDef
Set qdf = dbEngine(0)(0). QueryDef("qryTa bleOfGrades")
qdf.Parameters( "[Forms].[Form1].[Text22]") = [Forms].[Form1].[Text22]
Set rs = qdf.OpenRecords et(...
--
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.ne twrote in message
news:6ITai.191$ cx4.168@trnddc0 7...
>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.OpenRecordse t("SELECT * FROM qryTableOfGrade s")
'where qryTableOfGrade s 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.OpenRecordse t("qryTableOfGr ades")
I get "Run time error 3061 Too few parameters. Expected 1."
And if I do this:
Set rs = db.OpenRecordse t(qryTableOfGra des) ' without quotes
I get "variable not defined."
If I run the query by itself without the report it runs fine.