Access error reference
Access runtime error 3061: “Too few parameters. Expected 1.”
The query opens fine by hand, but the VBA code that uses it stops on “Too few parameters”. The message only says how many names Access could not resolve, never which ones.
The message
Run-time error '3061': Too few parameters. Expected 1.
On a French Access: « Trop peu de paramètres. 1 attendu. »
Where it shows up
Almost always in VBA code that runs a query through the database engine: CurrentDb.OpenRecordset, CurrentDb.Execute, QueryDef.OpenRecordset. Opened from the navigation pane, the same query does not raise 3061: Access shows an “Enter Parameter Value” prompt instead.
Common causes
- a field that was renamed, deleted or misspelled in the query: the engine treats any unknown name as a parameter;
- a reference to a form (
[Forms]![Customers]![txtCity]): the Access user interface resolves it, the engine called from VBA does not; - a text value concatenated without quotes into SQL built in code (
"WHERE City = " & Me.txtCity): the typed value becomes an unknown field name; - a declared parameter (
PARAMETERS) that the code never fills in.
How to reproduce and check it
- Open the query in Datasheet view: the “Enter Parameter Value” prompt shows the name Access does not know.
- For SQL built in VBA, print it (
Debug.Print strSQL), paste it into a new query in SQL view and run it: same effect. - Compare the requested name with the table's fields: one letter, a space or a renamed field is enough.
How to fix it
Restore the field name if it changed. For a form reference, fill in the parameters before opening the query:
Set qdf = CurrentDb.QueryDefs("MyQuery"), then For Each prm In qdf.Parameters : prm.Value = Eval(prm.Name) : Next, then Set rs = qdf.OpenRecordset().
For a text value, wrap it in quotes and double any quote inside it ("WHERE City = '" & Replace(Me.txtCity, "'", "''") & "'"), or better, use a parameter.
What Auscult reports
The diagnostic recognises 3061 (the “parameter” family) on every query, form, report or button where Access returns it. The full report names what the query refers to without defining it and, when an existing field has a very close name, proposes it as the fix. A query that, opened on its own, asks for a value its form normally supplies is not reported as broken: it is marked “to check”.
Measured on our test corpus: this message was recorded while analysing 251 of 965 applications.
Related errors
- 3075 — missing operator, often the same badly concatenated value
- 2465 — can't find the field, the same renamed field seen from a form
- The Access error reference, code by code