Opening Access DB with /compact operator

koltregaskes

New Member
Joined
Feb 8, 2005
Messages
15
I believe this is a questioned asked many times but I've yet to find a solution. I'd like to compact my Access DB before I run a few macros in it. I know there are various ways of doing this but everything I've tried doesn't work. I noticed that you can add /compact operator to a shortcut to the DB to open, compact and close the DB. So is there anyway you can run this? My current code is:

Dim CompactDB
CompactDB = Shell("C:\PM REPORT\PM Report Generator 2.accdb", vbNormalFocus)

If I try and add the /compact operator either inside the speech marks our after it gives me an error. Any ideas if there is a way to get this working?

I've had lots of problems running Access queries from Excel but swapped the Access queries to macros and that seems to work but I still get errors that are fixed once I compact the DB. I'd like the compacting to be automated. :-)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top