RepairDatabase Method Example

This example attempts to repair the database named Northwind.mdb. You cannot run this procedure from a module within Northwind.mdb.

Sub RepairDatabaseX()

   Dim errLoop As Error

   If MsgBox("Repair the Northwind database?", _
         vbYesNo) = vbYes Then
      On Error GoTo Err_Repair
      DBEngine.RepairDatabase "Northwind.mdb"
      On Error GoTo 0
      MsgBox "End of repair procedure!"
   End If

   Exit Sub

Err_Repair:

   For Each errLoop In DBEngine.Errors
      MsgBox "Repair unsuccessful!" & vbCr & _
         "Error number: " & errLoop.Number & _
         vbCr & errLoop.Description
   Next errLoop

End Sub