Dim TempStr As String
Dim OrigStr As String
OrigStr = "C:\DB1.mdb"
On Error Resume Next
DBEngine.RepairDatabase OrigStr, TempStr
FileCopy TempStr, OrigStr
In most cases MS-Access inbuilt utilities recover these kind of corrupted databases, but its not guaranteed that it can your database too.
For this problem one software comes in my mind Stellar Phoenix Access Recovery it will help you to recover data which is not accessible due to corruption in Access databases, Tables, Queries, Forms, or Reports.
Just try free trial version <url snipped> it will scan your database and after that you will be able to see your recovered database.
If you are pleased with that buy full version of this software so that you can save your recovered database.
You can use following method and code to recover corrupted database.
1.DBEngine.CompactDatabase strInput strOutput
This compacts the database. strInput is the database file to be actioned on and strOutput is the resultant compacted database file name.
2. DBEngine.RepairDatabase strInput
This repairs a database. A trapable error 3049 can be checked for. This error indicates the database is possibly corrupt and therefore RepairDatabase method can be implemented.
To open a database exclusively:
Set db = dbEngine.Workspaces(0).OpenDatabase (strDBase,True)
If still errors comes, it means database is critically corrupt. You should have backup of this database file or use some good access repair software like Stellar Phoenix access recovery. This supports all version of microsoft access and in demo version you can check your repaired database.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...