Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access error 7874: Microsoft Access can't find the object (fix)

A button runs a query, opens a table or runs a macro, and Access answers that it can't find the object. The name quoted does not exist, or no longer exists, in the Access database.

The message

Microsoft Access box: “Microsoft Access can't find the object 'Commandes'.”, followed by two possible causes
The real Access box, captured in Access for Microsoft 365, in English: a macro opens the table “Commandes”, which does not exist in the database.

Microsoft Access can't find the object '…'.

English Access; in quotes, the object named by your application

On a French Access: « Microsoft Access ne peut pas trouver l’objet « … » ». The English version sometimes puts a full stop just before the closing quote.

Where it shows up

Mostly with DoCmd: DoCmd.OpenQuery, DoCmd.OpenTable, DoCmd.DeleteObject, and in a button's macros (OpenQuery, OpenTable).

Common causes

  • the object was renamed or deleted, and the code or macro keeps the old name;
  • a typo, an extra space or character in the name;
  • the object is in another file: a back-end table that was never linked, or a query left in an older version;
  • a name built by the code ("qry" & strType) that gives a non-existent name for some values.

How to reproduce and check it

  1. Copy the name quoted in the message and look for it in the Navigation Pane, showing all objects.
  2. In the VBA editor, search for that name across the whole project (Ctrl+F), then in the buttons' macros.
  3. If the name is built by the code, print it before the call: Debug.Print strQuery.

How to fix it

Restore the object or fix the name. For a variable name, check it exists before use, with a small function: On Error Resume Next: Set qdf = CurrentDb.QueryDefs(strQuery): Exists = (Err.Number = 0).

For a back-end table, relink it (External Data, Linked Table Manager) rather than changing the code.

What Auscult reports

The diagnostic records error 7874 with the button or macro that raises it. The report explains it as “A table or query that is needed cannot be found: deleted, renamed, or kept in a data file that did not come with the application” and suggests restoring it or removing what is no longer used.

When an object has a name close to the one quoted, the report often gives a proposed fix, to be checked: the object with the closest name (a likely typo or rename), and the line of code that keeps the old name.

The Access error reference, code by code

Frequently asked questions

The object does exist in the database: why error 7874?

Compare the names character by character: a trailing space, a hyphen instead of an underscore or an accented character is enough. Check the type too: DoCmd.OpenQuery does not find a table, and vice versa.

Can I delete queries that are no longer used?

Yes, after searching for their name in code, macros, form and report sources, and combo boxes. A name missing from the code can be written in a property.

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.