my CompactDB vba no longer works in Access2007

B

Bruce

Hi,

I have been using the macro below sucessfully in Access 2003. I have just
upgraded to MS2007 and my vba no longer works.

At this stage I do not plan to upgrade the DB from 2003 to 2007. Is there a
different way to do this so it works in both 2003 and 2007.

Bruce



Public Sub CompactDB()

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

End Sub
 
G

Gigamite

Bruce said:
Is there a
different way to do this so it works in both 2003 and 2007.

This works in A2K and later unless you've messed with built-in menus in
A2K7. Don't know for sure if it's going to work in A2K10 until that
gets released. I'm guessing it will.

Public Sub CompactDB()
If (SysCmd(acSysCmdAccessVer) >= "12.0") Then
SendKeys "%FMC", False
Else
CommandBars("Menu Bar").Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and Repair database..."). _
accDoDefaultAction
End If
End Sub
 

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