Monday, May 3, 2010

Compacting an Access DB via VBA

This was a great idea that I found on the internet.  It was on tek-tips.com.


Helpful Member!Helpful Member!Helpful Member!Helpful Member!WildHare (MIS)
2 Sep 03 15:39
Uhh.. toss this little puppy on a command button:

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

The kicker here is the last line. Note the acCDoDefaultAction.

Most other built-in guys use acSomethingOrOther, with only ONE "C" - I don't know if this was a deliberate thing or an acCident.. but this method works for A2K and above.


No comments:

Post a Comment