Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access error 3146: ODBC--call failed, how to find the real cause

An Access database linked to SQL Server, Oracle or MySQL through ODBC stops on “ODBC--call failed”. The message says almost nothing: the real cause is the server's message, which Access keeps alongside it.

The message

Access run-time error 3146 box
The run-time error box Access shows, in English: error number 3146 and its message.

ODBC--call failed.

English Access

Error number 3146 is the same in every language: search for it if your Access is not in English. Microsoft describes it as a failed operation on data in an ODBC data source, for example when the source is on the network and the network is not available.

Where it shows up

When opening a linked table, or a form or report based on it, when saving a record, in a pass-through query, or in code: CurrentDb.Execute, OpenRecordset on an ODBC linked table.

Common causes

  • the server does not answer: network down, VPN closed, server stopped or renamed;
  • the timeout is reached: a long query exceeds the query's ODBC timeout (60 seconds by default);
  • the server refuses the operation: insufficient permissions, duplicate key, constraint or foreign key violation, value too long for the column;
  • a pass-through query written wrongly for the server, or a linked table whose structure changed on the server.

How to reproduce and check it

  1. Replay the action, then open the linked table on its own: if it does not open, the problem is the connection, not the form.
  2. Read the server's message: in code, the DBEngine.Errors collection holds the driver's error, before 3146.
  3. Replay the same statement in the server's own tool (SQL Server Management Studio, for example) with the same account.

How to fix it

Start by showing the real cause, in the error handler and before any other DAO operation: Dim e As DAO.Error, then For Each e In DBEngine.Errors: Debug.Print e.Number, e.Description: Next e.

Then fix according to the server's message: account permissions, rejected data, or timeout. For a long query, raise the query's timeout: CurrentDb.QueryDefs("qryExport").ODBCTimeout = 300 (0 = no limit). If the server does not answer, see error 3151.

What Auscult reports

Auscult only runs the database on a copy. A server's data cannot be copied: so as not to change it, the analysis does not connect to the server. The report names the source (“server database (ODBC)”) and the linked tables that read it, and says what could not be tried without that data.

So it does not tell you whether the ODBC call fails on your network. To have the forms tried, analyse a copy of the database linked to local tables or to a test database.

The Access error reference, code by code

Frequently asked questions

Why does error 3146 only happen in the morning or when working from home?

Because it depends on the path to the server: VPN not yet open, slow network, server backed up overnight. The server's message, read from DBEngine.Errors, confirms it.

Should every query become a pass-through query?

No. Pass-through helps for heavy processing run by the server. An ordinary Access query on a linked table is enough for the rest, as long as the server accepts it.

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.