Access error reference
Access error 3151: ODBC connection failed (DSN, driver, server)
The Access database works on its author's PC but not on another: the ODBC connection fails before the first record. Most often, the data source or the driver does not exist on that PC.
The message

ODBC--connection to '…' failed.
On a French Access: « ODBC -- Échec de la connexion à « … ». »
Microsoft describes 3151 as the ODBC connection to the specified database or table not being made, for example when the network is not available.
Where it shows up
When opening a linked table or anything based on it, at start-up if a start-up form reads a server table, or in code that opens a connection (OpenDatabase, RefreshLink).
Common causes
- the DSN does not exist on this PC: linked tables keep the name of a data source created on the author's PC;
- the driver is not installed, or not the right version: 64-bit Office needs a 64-bit driver and DSN, 32-bit Office a 32-bit DSN;
- the server changed: new name, new address, renamed database, firewall;
- the account is refused: SQL login changed, or a Windows account with no rights on the database.
How to reproduce and check it
- Note the name quoted in the message, then look for it in the PC's ODBC Data Source Administrator.
- Check the version: on 64-bit Windows, the 32-bit administrator is
C:\Windows\SysWOW64\odbcad32.exe, the 64-bit one is inSystem32. - Test the connection from the ODBC administrator: if it fails there too, the problem is the PC or the server, not the Access database.
- In the Immediate window (Ctrl+G), type
? CurrentDb.TableDefs("dbo_Customers").Connectto read a linked table's connection string.
How to fix it
Create the missing DSN with the same name and the same bitness as Office, or remove the DSN dependency by linking the tables with a full connection string.
For example, for each linked table: tdf.Connect = "ODBC;Driver={ODBC Driver 17 for SQL Server};Server=SRV01;Database=Sales;Trusted_Connection=Yes;", then tdf.RefreshLink. Adapt the driver to the PC and the server name.
What Auscult reports
Auscult only runs the database on a copy and does not connect to servers: their data cannot be copied, and the analysis must not change it. The report names the source (“server database (ODBC)”, with its DSN when the database has one) and the linked tables that read it.
So it does not test the connection itself. It does show what depends on that server, and what could not be tried without it.
Related errors
- 3146 — ODBC--call failed, when the connection exists but the operation fails
- Can't find project or library, the other typical fault on a new PC
- The code in this project must be updated for 64-bit systems (PtrSafe)
- The Access error reference, code by code