Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access error 3051: file already opened exclusively or no access

The Access database no longer opens, or its linked tables refuse to show: the engine cannot open the file. Someone opened it in exclusive mode, or the Windows account lacks the permissions it needs on the file or its folder.

The message

Microsoft Visual Basic box: “Run-time error '3051': The Microsoft Access database engine cannot open or write to the file…”
The real error box, captured in Access for Microsoft 365, in English: the code opens a database the Windows account is not allowed to read.

The Microsoft Access database engine cannot open or write to the file '…'. It is already opened exclusively by another user, or you need permission to view and write its data.

Access for Microsoft 365, English; in quotes, the file path

On a French Access: « Le moteur de la base de données Microsoft Access ne peut pas ouvrir ou écrire sur le fichier « … ». Il est déjà ouvert en mode exclusif par un autre utilisateur, ou vous devez avoir l’autorisation de visualiser et d’écrire sur ses données. »

Microsoft gives two causes: you need permission to read the file's data, or you tried to open it exclusively while another user already has it open.

Where it shows up

When opening the database, at the first linked table read at start-up, or in code: OpenDatabase, RefreshLink, TransferDatabase, copying or compacting the back end.

Common causes

  • a user opened the database in exclusive mode, often to compact or change it;
  • the shared folder's permissions: read-only, or no right to create and delete the lock file (.laccdb or .ldb);
  • a process holds the file: a backup, an antivirus, OneDrive or SharePoint sync, an Access session left open in the background;
  • the “Open in exclusive mode” option set as default in a PC's Access options.

How to reproduce and check it

  1. Check whether a .laccdb (or .ldb) file sits next to the database: it signals an open session.
  2. Ask who has the database open; on the server, the share's open files list also tells you.
  3. Check with the user's account that they can create a file in the database's folder, and delete it.

How to fix it

Have the exclusive session closed, and untick exclusive mode in the PC's options (Access Options, Client Settings, default open mode “Shared”). Give users read, write, create and delete permissions on the folder, not just on the file.

In code, open the back end in shared mode: Set db = DBEngine.OpenDatabase(strPath, False, False) (second argument False: not exclusive; third False: not read-only). Move the database out of synced folders (OneDrive, SharePoint).

What Auscult reports

Auscult only runs the database on a copy. If one of the application's databases cannot be copied because it is open on another PC, or because the Windows account has no right to read it, the analysis runs nothing and says so. The report then advises closing the application on the other PCs, checking that the database opens from this PC, and running the analysis again.

The Access error reference, code by code

Frequently asked questions

Can I delete the .laccdb file to unlock the database?

Only when nobody has the database open any more: Access deletes it itself when the last session closes. If it stays and cannot be deleted, a session or a process still holds the file.

Is an Access database in OneDrive or SharePoint a good idea?

Not for a shared database: sync holds the file and does not handle Access locking. Put the back end on an office network share.

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.