Access 2007 does not like this code

S

SF

Hi,

I have a function to compact Database below, it works well in Access 2003.
Access 2007 give me an error.

Public Function CompactPACTDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

End Function


SF
 
G

Graham R Seach

What you're looking for is:
CommandBars("Menu Bar").Controls("&Tools").Controls("&Database
Utilities").Controls("&Compact and Repair Database").Execute
....or...
Application.CompactRepair

....but you can't compact the current database in code.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top