'I use the next code to do some actions with a access database
'just make a new project; a form with a commondialog control (name = CommonDialog1)
'four commandbuttons (index 0 to 3)
'make sure you have set a temp-directory!

Const strDataBaseLocation As String = [the directory where teh database is; ended with a backslah!]
Const DataBaseNaam As String = [the name of the database with extension]
Dim db As Database

Sub Form_Load

	Set db = OpenDataBase(strDataBaseLocation & DataBaseNaam)

End Sub

Private Sub mnuDatabase_Click(Index As Integer)
    Dim lngResult As Long
    Dim lngError As Long
    Dim strSource As String
    Dim strTarget As String
    Dim strTempory As String
    
    On Error GoTo ErrDatabase
    
    Screen.MousePointer = vbHourglass
    strSource = strDataBaseLocation & DataBaseNaam
    strTempory = Environ("temp") & "\compact.mdb"
    
    On Error GoTo ErrDatabase
    
    Screen.MousePointer = vbHourglass
    Select Case Index
    Case 0  'backup
        With mdiMain.CommonDialog1
            .filename = "backup"
            .DefaultExt = "mdb"
            .ShowSave
        End With
        strTarget = CommonDialog1.filename
        lngResult = CopyFile(strSource, strTarget, lngError)
    Case 1  'import
        With CommonDialog1
            .filename = "import"
            .Filter = "(*.mdb)|*.mdb"
            .DefaultExt = "mdb"
            .ShowOpen
        End With
        strTarget = CommonDialog1.filename
        lngResult = CopyFile(strTarget, strSource, lngError)
    Case 2  'repair
        lngResult = CopyFile(strSource, strTempory, lngError)
        RepairDatabase strTempory
        Kill strSource
        lngResult = CopyFile(strTempory, strSource, lngError)
    Case 3  'compact
        CompactDatabase strSource, strTempory
        Kill strSource
        lngResult = CopyFile(strTempory, strSource, lngError)
    End Select

    Screen.MousePointer = vbNormal
    Exit Sub
    
ErrDatabase:
        
End Sub
Return