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 |