Article ID: 815280
Article Last Modified on 10/14/2003
APPLIES TO
- Microsoft Access 2000 Standard Edition
This article applies only to a Microsoft Access database (.mdb).
Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
This article describes how to recover data from a corrupted table in an Access database. You can do this by using the Microsoft Data Access Objects (DAO) db.Execute method. You can use the db.Execute method when you cannot recover your data by using either MS Query or the Compact and Repair Database utility in Access.
MORE INFORMATION
Note The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
To recover the data from the corrupted table in Access, follow these steps:
- Make a copy of the corrupted database. Exclude the corrupted tables. Name the database Recovered_Database.
- Open the Access database that contains the corrupted tables.
- Click Modules and then click New.
Put the following code in the new module:
Note The following code creates a table in Recovered_Database with the same name as the corrupted table (<Corrupted_Table>).Sub Recovery() Dim db As Database Dim sql As String ' Set the database to current database. Set db = CurrentDb() ' Set sql to a string that represents the query to recover data from ' the corrupted table. <Corrupted_Table> is the name of corrupted table. sql = "SELECT <Corrupted_Table>.* INTO <Corrupted_Table> in " & _ "'<Absolute_Path_of_Recovered_Database>\Recovered_Database.mdb'" & _ " FROM <Corrupted_Table>" db.Execute sql End Sub
- On the File menu, click Save. Save the module as Module1.
- On the Run menu, click Run Sub/UserForm.
- Repeat step 3 to step 6 for each corrupted table.
After you complete these steps:
- Test the recovered database before you return the database to the production environment.
- Do not delete the damaged database until you confirm the recovery.
REFERENCES
For additional information about troubleshooting the corrupted database and how to recover data from a corrupted table, click the following article numbers to view the articles in the Microsoft Knowledge Base:
306204 ACC2000: How to Troubleshoot Corruption in a Microsoft Access Database
209137 ACC2000: How to Troubleshoot and Repair a Damaged Jet 4.0 Database
247771 ACC2000: How to Recover Data from a Damaged (Corrupted) Table
304561 ACC2000: How to Use MS Query to Recover Data from a Damaged Jet 4.0 Database
Additional query words: Recovery corrupt corrupted table database Acc2000 recover
Keywords: kbhowto KB815280