Summary: This blog describes easy solutions to fix ‘cannot compact/repair db because file is already in use’ error. You’ll also get know about a specialized software such as Stellar Repair for Access that can help you restore your database and all its data in a few simple steps.
Following are some situations where you may need to compact and repair an Access database:
Sometimes, when trying to compact an Access database (located on a server), you may encounter an error message ‘cannot compact/repair db because file is already in use’.
Following are the solutions you can try to fix the error:
In Microsoft Office Access, a lock file is created when you open or access a database. The file has the same name as the database but with an extension “.laccdb” for .accdb databases and “.ldb” for .mdb databases. The lock file is automatically deleted when you close the database. However, the file might not get deleted if the database is exited abnormally.
You cannot access the database file and recover its data unless the lock on the .accdb/.mdb file is removed. This is why, you may receive “file already in use” error message when compacting an Access database. To resolve the issue, check if there is a “.laccdb” or “.ldb” file in the same folder as that of your db file. If yes, then you must delete the “.laccdb” or “.ldb” file to remove the lock on an Access database file and recover its data.
Another solution you can try to resolve the issue is to compact the database, without opening it, from command line.
|Note: Before compacting and repairing an Access database from the command line, make sure: Microsoft Access program is installed on your system.If you don’t have MS Access installed on the system, download and use Jet Compact Utility.|
To compact Access db from the command line, type the following command in the command prompt window and then press the ‘Enter’ key:
msaccess <path to database file>\<database file name> /compact
In the above command, replace ‘<path to database file>’ with your database path and replace ‘<database file name>’ with your Access database filename. For instance:
msaccess.exe “C:\Program Files\EmployeesDB.mdb” /compact
This will begin compacting and repairing your Access database file.
If you cannot access the database, using a specialized Access database repair software, such as Stellar Repair for Access can help you repair and recover your database (.accdb/.mdb) files quickly in just a few clicks. The software restores all the database objects, like deleted records, password-protected forms, indexes, modules, etc.
Steps to Repair an Access Database with Stellar Repair for Access Software
When trying to compact and repair an Access db, if you keep getting the message ‘Could not use ‘C:\….accdb’; file already in use.‘, the first thing you can do is to view and delete Access lock file. If you cannot find the lock file (.laccdb or .ldb), try compacting and repairing the db from command line. If the manual solutions fail to compact/repair an Access db file, you can use an Access repair software, such as Stellar Repair for Access to repair the db and recover all its data. The software is purpose-built to help users repair severely corrupted Access database and retrieve all its records, including deleted records.
Charanjeet is a Technical Content Writer at Stellar®who specializes in writing about databases, e-mail recovery, and e-mail migration solutions. She loves researching and developing content that helps database administrators, organizations and novices to fix multiple problems related to MS SQL and MySQL databases and Microsoft Exchange.
Powerful tool, widely trusted by users &Read More
Stellar Repair for MS SQL is an enterpriRead More
Stellar Repair for Excel software providRead More
Stellar Repair for MySQL is an advancedRead More