Automate compact and repair

In an Access 2000 database in Access 2003 (Dutch) I have the following code:

Option Compare Database
Option Explicit

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

Private Sub test2_Click()
CompactDB
End Sub

Following references are checked:
- Visual Basic for Applications
- Microsoft Access 11.0 Object Library

When I press the test2 button I keep getting the error message:
Invalid procedure call or invalid argument.

What am I doing wrong?
Thanks,
John
Johnie [ Di, 25 Dezember 2007 22:50 ] [ ID #1893588 ]
Datenbanken » comp.databases.ms-access » Automate compact and repair

Vorheriges Thema: Scan with Object or DAO.Recordset
Nächstes Thema: Vista Issues Explained