You can use the ‘Compact on Close’ option in Access to automatically compact and repair the Access database that is currently open. Follow the steps below:
Select File > Options.
In the Access Options dialog box, select Current Database.
Under Application Options, select the Compact on Close checkbox.
Select OK.
Close and reopen the database for the option to work.