How to Compact and Repair an Access Database
Short answer: To compact and repair an Access database, make a backup, make sure nobody else has the file open, then open the database and go to File > Info > Compact & Repair Database. If the database will not open, start Access with no database open and use Database Tools > Compact and Repair Database to pick the file. Compact and Repair rebuilds the file, frees unused space and fixes some minor corruption. It is not a backup, and it cannot fix every damaged file.
Contact Us Today
Call +1 773.809.5456, email [email protected], or send us a message using the form below.
What does Compact and Repair actually do?
Compact and Repair is often described as a way to “shrink” an Access database, but it is more accurate to think of it as a rebuild. Access creates a new, compacted copy of the database and leaves out the space that is no longer used. It does not compress your data like a ZIP file.
A successful compact can:
- Reclaim space left behind by deleted records and deleted objects.
- Remove temporary or unused space created during normal use.
- Reduce the file size when a lot of unused space has built up.
- Improve speed when file growth was slowing things down.
- Repair some minor corruption that Access can recognize and rebuild safely.
Compact and Repair is not a substitute for a backup, and it cannot recover a badly damaged file. A database can compact without errors and still have damaged objects or missing data, so always check the result before you put it back into use.

Why Access databases grow even after you delete data
An Access file does not get smaller when you delete records or objects. The space becomes reusable inside the file, but the file size stays the same until you compact it.
Common causes of growth:
- Frequent append, update and delete queries.
- Make-table queries and processes that create and delete temporary tables.
- Large imports that are later removed or replaced.
- Development work that keeps creating and changing forms, reports, modules and queries.
- VBA code that creates temporary objects.
- Many users adding and removing records in a busy database.
If the file becomes much smaller after compacting, that does not mean data was lost. Usually the file just had a lot of unused space. Still compare record counts and test the main features after any repair, especially if you suspected corruption.
Before you compact and repair: 5 safety checks
These checks matter more than the button itself. Do them before every repair on an important database.
Step 1: Make a backup copy. Copy the database before you change anything. If the database already shows signs of corruption, keep an untouched copy before you try anything.
Step 2: Get exclusive access. Compact and Repair needs everyone else out of the file. In a shared database, plan a maintenance window.
Step 3: Check folder permissions. Access creates a new file during the compact, so it needs permission to write to the database folder.
Step 4: Check free disk space. The compact needs room to build the new file. Very large files or nearly full disks can make it fail.
Step 5: Know which file you are repairing. In a split database, the front end and back end are separate files. Compact the right one, and do not replace a live back end until you have checked the repaired copy.

How to compact and repair a database in Access (when it opens)
-
Step 1: Open the database
Open the database in Microsoft Access (Microsoft 365, Access 2024, 2021, 2019 or 2016). Make sure you are the only person using it.
-
Step 2: Run Compact & Repair Database
Go to File > Info and select Compact & Repair Database. Wait until Access finishes. Access builds a compacted and repaired copy in the same folder and then uses it in place of the old file.
-
Step 3: Test the database
Reopen the database if needed. Test the main forms, queries, reports, tables and VBA code.
In Access 2010 and 2013 the command works the same way, but its place in the menu can be slightly different.
How to compact and repair Access database files without opening them
If Access cannot open the damaged file, you can still run Compact and Repair. The trick is to open Access itself, but not the database.
-
Method 1: Run Compact and Repair from Access with no database open
- Make a copy of the damaged .accdb or .mdb file and keep the original.
- Start Microsoft Access. If it opens a database on its own, close that database.
- Go to Database Tools > Compact and Repair Database.
- In the Database to Compact From window, find and select the damaged file.
- Let Access create the compacted and repaired copy.
- Open the repaired copy and check the data and objects before you replace anything in use.
-
Method 2: Use the /compact command-line switch
Access also has a
/compactstartup switch. It is useful for scheduled maintenance or for starting the compact from a shortcut.
The path to MSACCESS.EXE depends on your Office install. A 32-bit Office on 64-bit Windows may be under Program Files (x86). Test the command on a copy before you use it in a scheduled task.
How to compact an Access database automatically on close
For databases that build up unused space quickly, Access can compact the file every time it closes.
- Open the database.
- Go to File > Options > Current Database.
- Under Application Options, select Compact on Close.
- Click OK, then close and reopen the database.
Compact on Close works well for single-user databases. In a shared database it needs exclusive access and can lock others out for a moment, so a planned maintenance time is usually safer. The setting only applies to the database where you turn it on.
What to do when Compact and Repair fails
A failed Compact and Repair does not always mean the database is lost. The cause can be locking, permissions, storage or corruption. Work through these in order instead of running repair again and again on your only copy.
-
Step 1: File already in use, or no exclusive access
Make sure every user has closed the database. Check that no Access process is still running on another PC. Do not delete the lock file (.laccdb) while users are still connected.
-
Step 2: Permission or folder errors
Copy the database to a local folder where you have full access and try again there. Move the repaired copy back with your normal process once it is checked.
-
Step 3: Not enough disk space, or the file is near the 2 GB limit
Free up disk space and work from a local copy. If the database keeps getting close to the limit, the lasting fix is to move the data to SQL Server, not to compact more often.
-
Step 4: Access reports a partial repair
Access lists the objects it could not repair in a table named MSysCompactErrors. Use it with a good backup to decide what to restore or rebuild.
-
Step 5: It still fails, or the repaired file is unstable
Stop repairing the original. Keep the source file and work on copies. The next safe step is usually to create a new blank database and import the objects that still work, or to restore a clean backup. Our guide shows how to fix a corrupt Access database step by step.
If Access also shows the message that the database is “in an inconsistent state”, see our guide to the inconsistent state error.
Compact and repair in a split Access database
Many Access applications are split into a front end and a back end. The front end holds forms, reports, queries, VBA and the linked tables. The back end holds the shared data.
- Front end: each user should have their own local copy. If one gets bloated or damaged, replace it with a clean copy instead of repairing it.
- Back end: compact it only when all users are disconnected. Back up first, work in a planned window, and check the repaired file before users reconnect.
- Do not compact a shared back end over an unreliable network if you can do it locally instead.
If a shared database keeps getting corrupted, more Compact and Repair is not the full answer. Review how the database is deployed, the network, and the design.

How often should you compact and repair an Access database?
There is no fixed schedule. A database that is mostly read may rarely need it. One that imports, deletes or rebuilds data all the time can build up unused space fast.
Signs it is time:
- The file has grown a lot without a matching increase in real data.
- Forms, queries or normal work have become slower.
- You just finished a large cleanup, import, delete or development cycle.
- Access reported corruption or asked you to repair the database.
If the file grows back right after every compact, find out what is creating the growth.
How to reduce future bloat and corruption
- Split shared databases so each user works with a local front end.
- Keep tested backups, and know how to restore them.
- Do not let several users edit one unsplit file over an unstable network.
- Review VBA code that keeps creating and deleting temporary tables or objects.
- Watch the file size instead of waiting until it gets close to the 2 GB limit.
- Give users a fresh front end when needed instead of repairing old copies.
What Compact and Repair does not fix
A smaller file is not proof that every problem is solved. Compact and Repair does not fix poor table design, slow queries, broken business logic, wrong relationships, VBA bugs or a poor multi-user setup. If the database is still slow after a successful compact, find the real cause: query design, indexes, network speed, linked tables, heavy forms, VBA or data volume.
For more help with errors, see all our Microsoft Access troubleshooting guides.