Access 2007 does not like this code

  • Thread starter Thread starter SF
  • Start date Start date
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
 
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
 
Back
Top