Repair External Database

This example repairs a database. It will not repair the current database. The full path of the database must be passed to the routine.

Note that the use of SendKeys can cause problems. See The Access Web for more information.

'***************** Code Start *******************
'This code was originally written by Terry Wickenden.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.

Sub DBRepair(strRepair As String)
   On Error GoTo errDBRepair
   SendKeys strRepair
   SendKeys "{ENTER}"
   RunCommand acCmdRepairDatabase
   Exit Sub
errDBRepair:
   Select Case Err
     Case 2501
       'Cancel Button selected in the repair database dialog
     Case Else
       MsgBox Err.Number & ":- " & vbCrLf & Err.Description
    End Select
End Sub

'****************** Code End ********************

Return to Example List