Cannot Compact And Repair Access Database – File Already In Use

After the File Lock bug, we have now seen many reports of people no longer able to Compact and Repair their databases and are receiving error messages such as:

Could not use [filename] file already in useMicrosoft Access

Here is a small sampling of the various forum threads on the subject:

and many, many more.

This was reported, multiple times, to Microsoft but we have yet to hear anything from them on the subject.

After several weeks, the Access community of users has identified the culprit as being: McAfee Antivirus.  Several people are reporting that uninstalling McAfee resolves the issue.  That said, before outright uninstalling it, I’d first try creating an exception for the Microsoft Access executable, msaccess.exe (This has been confirmed as an effective workaround).

If you do uninstall it completely, be sure to enable Windows Defender.  You do not want to find yourself without an active antivirus in 2022!

I’d also highly recommend, as a McAfee user, that you contact McAfee to report this.

If you can, please leave me a comment telling me if this resolved the issue for you or not.

21 responses on “Cannot Compact And Repair Access Database – File Already In Use

  1. CHRISTIAN

    Grazie infinite, creando un eccezione per Access il problema si è risolto.
    Cordiali saluti

    Thank you so much, creating an exception for Access solved the problem.
    Sincerely –From Google Translate and added by Admin

  2. Mike Wolfe

    We’ve had a couple of users in the past week get what may be a related error message when opening one of our applications with the /excl flag appended to the command line: “The database you are trying to open or convert is currently in use, or you do not have permission to open it exclusively.”

    The two users with the error message appear to be running very new versions of Access. I believe one was on Version 2202. I think it was also a C2R version. If it happens again, I’ll be sure to look for McAfee on their machine. Thanks for the heads up!

  3. Norbert Rovira

    Thanks for sharing this.
    Haven’t used Access for a while and this issue was driving me crazy.

    Deactivating McAfee temporarily worked fine as a solution.

  4. Stephan Leigh

    In a chat session with McAfee they had me turn off Real-Time Scanning and Firewall. I was then able to C and R. I still don’t know if this is a McAfee issue or a MS issue.

  5. Steve Leigh

    For what it’s worth, I just spent an hour with McAfee trying to figure out why “Exclude Files” doesn’t really exclude files from real-time scanning. So far, no resolution but the case has been escalated. I still have to temporarily stop real-time scans and stop the Firewall.

  6. Randi

    Thanks for the tip. This error drives me nuts! I also tried to exclude the accdb file from McAfee but it didn’t work. I temporarily turned off real-time scanning and it worked like a charm.

  7. Ted Coombes

    I had exactly same problem on 3 machines. One windows 11 and Access365 64 Bit, another Windows 10 and Access 365 64 Bit, and third Windows10 and Access 365 32 Bit. Had McAfee All access on all three machines. I had the issue when compacting and Repairing but also when trying to Create an ACCDE.

    Turn off McAfee All Access Real Time Scanning and then it all worked. Only thing I found was after it was done if you tried to do it a second time it said Query did not have enough memory which was odd as I have 32 GB Ram. Found that it then was OK if I did a restart. Maybe it leaves stuff tied up in memory.

    Then tried switching Realtime Scanning back on and making exception of MSAccess.exe file and it then also works. but with same problem of tying up memory after it was completed until I did a restart. But at least I know have a way of making an ACCDE.

  8. Marc Faber

    Access does the compact and repair, but leaves the access application open in memory. Never had that issue with running Access 2010. Running Access on Windows Server 2019. Does the Access365 version use more memory to do the compact and repair?
    I have a separate macro that first deletes all the data in larger tables, then do the compact and repair to make sure that it won’t be larger than 2gb. But yet it will still come up with a warning that the query can’t finish and the dB might exceed the 2gb limit. I then need to end the task in task manager and all is fine. But I had this running on multiple databases fully automatic and have to now do this step manually to avoid things blowing up when repopulating the tables. Very strange!

  9. Harald Weninger

    Thank You very much for that article about the problem with Access. Finally you have saved my problem!!!
    I work with Windows 11, Office 365 Personal and use McAfee Total Protection.
    Compact and repair did not work on all Access-Programms when Live-Scan is activated.
    Creating an exception for Access solved the problem.
    Thankyou
    Harald

  10. Patti

    I added the exclusion for msaccess.exe in my McAfee and the error I was seeing while trying to “Compact and Repair Database” in ACCESS has gone away. Thank you for finding and solving and posting this fix.

  11. Lourens

    I HAVE THE SOLUTION!!! EUREKA!
    When Compact&Repair no longer works in Access, it may be caused by the “Trust Center”.
    In this case, you get a hazy message that Compact&Repair cannot be executed because “Could not use [filename] file already in use” (even if you are the only one).
    In my case, I have been working with the same database for more than 10 years and have always migrated it to a newer Office version (migrate by just opening the database in the newer version).
    If you add a safe location such as “C:\ and all subdirectories” to the “Trusted Center” in Options in Access, then you can suddenly use “Compact&Repair” again.
    An alternative for this problem (before I had found this “trusted” solution) I had also found. When you open the database from another device on your primary desktop/laptop (via shared volumes etc.) or via a shared network, then you can use the Compact&Repair option even when the Trusted Center is corrupted. However, sometimes, suddenly even that doesn’t work anymore.
    By the way, my database is split and I just changed the Trust center options once in the primary database, compact & Repair works in both parts now, before in non.
    I use Bitdefender and many others and even when I closed all Virus apps Compact&Repair did not work.

    I hope this helps.
    I was looking for an answer for 3 Years.

  12. Linda Richardson

    I am running Windows 10 and have uninstalled McAfee, but still cannot Compact and Repair. The message ‘… file in use’ still appears although only I am using the database. Is there anything else I could do?

  13. Tom

    The workaround of adding MSAccess.exe to the McAfee exclusion list worked like a charm! Thanks Daniel!

  14. Ray Higginbotham

    I have been receiving the “—file already in use” error messages when trying to compact and repair databases and when trying to convert from ACCDB to ACCDE. After temporarily turning off McAfee real-time scanning, was able to carry out both operations with no problem. So is McAfee the villain here? I don’t think it’s quite as simple as that. Until recently I had Windows 7, Access 2013 and McAfee and never had any problems. In April I “upgraded” to Windows 11 and Access 2016 and immediately the problems started. Is it perhaps down to the interaction between McAfee and Windows 11, Access 2016 and probably also later Access versions?

    1. Daniel Pineault Post author

      Hmmm. Everything works until McAfee is installed and running, thus McAfee is the source of the issue. Even if it is a conflict with Windows, McAfee is the trigger none the less.

      Did you contact McAfee’s support to see what they say?
      Did you try adding an exception rather than completely turning off real-time scanning?

      One way or another, it is up to software developers to ensure their software runs properly without adverse effects. This is why Microsoft has things like the insiders program, so software developers can develop and test prior to release. So it is on McAfee to ensure their app runs properly on Windows 10, 11 and beyond. It is simply the way software development works. Microsoft doesn’t change for us, we adapt to it. This is why many of us are constantly jumping through hoops trying to keep up. Just think of the 32 to 64-bit jump. We all had to adapt our code to the new reality, just as McAfee has to adapt to any change that Windows 10, 11, … may have brought on.

      I also wonder, did you check your version of McAfee on your Windows 7 vs Windows 11 machines? I highly suspect the version/build may not have been identical.