AFAIK, you can't compact the current db from VBA, using
Application.CompactRepair
quote from the Help topic says
"The source file must not be the current database or be open by any other
user, since calling this method will open the file exclusively."
but you can compact from the switchboard form with a custom menu bar, custom
toolbar, or custom shortcut menu. just create the custom object and copy the
Compact and Repair option from the built-in menu Tools, Database Utilities.
note that this action will close, compact and reopen the database just as it
does when you select it from the built-in menu in the database window. you
don't have to have the db open exclusively, but you should be the only user
in it at the time.
hth