Fix it now
The engine was handed a name it cannot resolve. Something was renamed, deleted, or moved to a back-end that is no longer linked, or a query is being asked for a parameter that nothing supplies. Read the name in the message first – it is the whole clue – and find out whether the object exists at all.
- Read the name the message gives you and look for it in the Navigation Pane. If it is not there, it was renamed or deleted and everything else follows from that.
- Show what is hidden before you conclude it is gone: right-click the Navigation Pane header, open Navigation Options, and tick Show Hidden Objects and Show System Objects.
- If the missing name is a table, check whether it is a linked table whose back-end has moved. Open the Linked Table Manager and relink to the current location.
- If the number is 3061, open the query in SQL view and look for a reference to a form control or an undeclared name. Opening the query by hand prompts you for it; running it from code does not, which is why the same query works one way and not the other.
- If the number is 2465, open the form or report in design view and check that every field named in a control source, a conditional format or an event exists in the Record Source.
- Before the next rename, run Database Tools > Object Dependencies on the object first and read what depends on it.
Renaming the object back to what everything expects is usually faster than fixing every reference to it, and it is far easier to reverse if you guess wrong.
If the queries return rows and the forms open, stop here. The next section explains where these names are stored and why renaming one thing breaks five others.
Why it happens
Queries, forms, reports and macros store the names of the objects they use as text. Nothing holds a durable link to an object’s identity, so renaming a table does not rewrite everything that referred to it. Access has a tracking feature that repairs some of these references automatically, but it only covers certain object types, it only works if it was on before the rename, and it never reaches into VBA or into SQL that code assembles as a string at run time. Which is why a tidy-up on Friday produces a pile of tickets on Monday.
In a split database the same failure arrives from a different direction. The front-end holds links pointing at a specific path to the back-end. Move the back-end, rename the share, or hand a copy of the front-end to somebody whose drive letters differ, and every linked name stops resolving at once. The message names a table, which makes it look like an object problem when it is a path problem, and the giveaway is that several tables are missing rather than one.
3061 is the most misread of the group. It appears when a query containing a parameter runs somewhere that cannot supply it. Open the query from the Navigation Pane and Access prompts you, so it looks like it works. Run the same query from code with OpenRecordset and nothing prompts, so the engine reports that it expected parameters it did not get. A reference to a form control counts as a parameter, and so does a misspelled field name – which is why a typo can present as a parameter error rather than as a missing field.
An object was renamed or deleted
You have this one if The name in the message is not in the Navigation Pane, and the trouble started after somebody tidied the database.
- Use Database Tools > Object Dependencies to find what referred to it, or export the query definitions and search the text.
- Rename the object back to what everything expects, which is usually faster than editing every reference.
- If it was genuinely deleted, recreate it or restore it from a backup copy of the database.
The back-end is not linked
You have this one if Several tables are missing at once, they are all data tables, and the front-end was copied from another machine.
- Open the Linked Table Manager and read the path shown against each link.
- Relink to the current back-end using a UNC path rather than a mapped drive letter, so it resolves the same way for everybody.
- Store the back-end path in a settings table and relink at startup in code, so the next move is a one-line change.
A query needs parameters that nothing supplies
You have this one if 3061, and the query runs correctly when opened by hand but fails from a button or from code.
- Open the query in SQL view and identify every reference to a form control or an undeclared name.
- Either open the form the query depends on before running it, or supply the parameters explicitly in code using the pattern below.
- Check for a misspelled field name, which the engine also treats as an unresolved parameter.
An expression names a field that is not in the record source
You have this one if 2465 on a form or report, usually after the Record Source was changed or a query column was renamed.
- Open the object in design view and read its Record Source.
- Confirm every field named in control sources, conditional formats and event code exists in that record source.
- Add the missing column to the underlying query, or correct the reference.
- Watch for a control and a field sharing a name, which makes an expression ambiguous and can resolve to the wrong one.
Code reads a recordset that has no rows
You have this one if 3021, raised on the line that reads a field value rather than on the line that opened the recordset.
- Test for both beginning-of-file and end-of-file before touching any field.
- Handle the empty case explicitly rather than leaving it to an error trap.
- Check whether the criteria should have returned rows at all, because an empty result is often the real bug.
Full reference
Supplying parameters from code
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set qd = CurrentDb.QueryDefs("qryOrdersByCustomer")
qd.Parameters("[Forms]![frmMain]![cboCustomer]") = Forms!frmMain!cboCustomer
Set rs = qd.OpenRecordset(dbOpenSnapshot)
If Not (rs.BOF And rs.EOF) Then
Debug.Print rs!OrderTotal
End If
rs.Close
Set rs = Nothing
Set qd = Nothing
The BOF and EOF test in that block is not decoration. Microsoft’s published description of 3021 is that either BOF or EOF is True, or the current record has been deleted, and the requested operation requires a current record. Testing both before you read a field is the whole prevention.
Which number tells you what
| Number | Where the failure is | First thing to check |
|---|---|---|
| 3078 | A table or query name the engine cannot resolve | Does the object exist, and is it a link whose back-end moved |
| 3061 | Parameters the caller did not supply | Form control references in the query’s SQL, and misspelled field names |
| 2465 | A field named in an expression that is not in the record source | The object’s Record Source, then every control source on it |
| 3021 | Code read a field with no current record | Test BOF and EOF before reading anything |
Renaming without breaking things
- Run Object Dependencies on the object and read the whole list before you touch it.
- Search the VBA project for the old name, because dependencies do not cover code.
- Search for SQL that is built as a string at run time, which nothing can track for you.
- Rename, then compile the project with Debug > Compile and open every affected object.
- Keep a copy of the database from before the rename until you are satisfied.
Name AutoCorrect, honestly
The tracking feature repairs some references automatically after a rename. It also stores tracking data inside the file, it does not cover VBA or dynamic SQL, and it only helps if it was enabled before the rename happened. Plenty of developers leave it off and rename deliberately using dependencies instead. Either position is defensible; what is not defensible is assuming it will catch everything, because the references it misses are exactly the ones that fail at run time in front of a user.
When the object is there and Access still cannot find it
- Check for a trailing space in the object name, which is invisible and compares as different.
- Check for an underscore where the reference uses a hyphen, or a capital I standing in for a lower case l.
- Check whether the name shown in the Navigation Pane is a link whose target has gone; the name survives the link breaking.
- Check that the query is not referring to a query that refers to the missing object, which puts the real name one level away from the message.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
3078 |
The engine could not resolve the named table or query | not published by the vendor |
3061 |
The query expected parameters that the caller did not supply | not published by the vendor |
2465 |
A field named in an expression is not present in the record source | not published by the vendor |
3021 |
Either BOF or EOF is True, or the current record has been deleted, and the operation requires a current record | Microsoft Learn |
Confirm the fix worked
- Open every affected query and confirm it returns rows rather than an error.
- Open each form and report that depends on those queries and page through several records.
- Run the code path from the button that failed, not only the query from the Navigation Pane.
- Run Debug > Compile on the VBA project and confirm it compiles cleanly.
- Run Object Dependencies on the repaired objects and confirm nothing still points at a missing name.
Questions people ask about this
Is there anything to buy here?
No. This costs nothing to fix. Every tool involved is part of Access, and the fixes are corrections to names, links and code. A licence question only arises if a machine that has to run the database does not have Access on it at all.
Should I turn Name AutoCorrect on or off?
There are arguments both ways. It repairs some references automatically, but it stores tracking data in the file and never covers VBA or SQL built at run time. Many developers turn it off and rename deliberately, using Object Dependencies first. What matters is not assuming it caught everything.
Why does the query work when I open it but not from a button?
Because opening it interactively prompts you for any parameter it needs, and code paths never prompt. An unresolved reference becomes error 3061 instead of a dialog, which is why the same query appears to work and fail at the same time.
The table exists but Access still says it cannot find it.
Look for a trailing space in the name, a character that looks like another one, or a linked table whose link is broken even though the name still shows in the Navigation Pane. Opening the Linked Table Manager settles the last one immediately.
Do these numbers have published meanings I can quote to a vendor?
Only 3021, which Microsoft publishes in the ADO error list. For 3078, 3061 and 2465 there is no vendor-published definition, so describe what the application was doing rather than quoting a number at somebody.
