Skip to content
Auscultby NBIT
EN
Free diagnostic

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.

English Access (the number varies: “Expected 2”, “Expected 6”…)

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

  1. Open the query in Datasheet view: the “Enter Parameter Value” prompt shows the name Access does not know.
  2. For SQL built in VBA, print it (Debug.Print strSQL), paste it into a new query in SQL view and run it: same effect.
  3. 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.

The Access error reference, code by code

Frequently asked questions

Why does the query work by hand but not in VBA?

In the user interface, Access resolves references to open forms or prompts you for the value. The database engine called by OpenRecordset knows nothing about forms: any name it cannot find in the tables becomes a missing parameter.

Does “Expected 1” help?

It tells you how many names are unknown, not which ones. Opening the query by hand, or its SQL in a new query, makes Access name them one by one.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.