Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database corruption - please help

Status
Not open for further replies.

Danielbryanuk

Technical User
Sep 26, 2007
48
DE
Hi there folks

I hope you guys can help me with a database I created which now seems to be corrupted. When I try to open the database I get the message "'ID' is not an index in this table", and it wont let me open the database.

In the past I have simply compacted the database and everything returned to normal when encountering corruption with access databases. However when I try to compact via the tools menu it won't compact, and I get the message:

"Microsoft detected corruption in this file. To try to repair this corruption first make a backup copy of the file, then on the tools menu compact and repair database. If you are currently trying to repair this corruption you will need to recreate this file or restore it from a previous backup."

I have even tried importing objects to a blank database, which worked fine until I imported the main table when the error message reappeared!

Can you recommend anything to save the data in the corrupted table?
 
Thanks very much, the link pretty much describes the problem. I am having trouble with the VB syntax, as I am not a regular user. The file path of the corrupted database is "K:\Probate 2007.mdb", but when I substitutue this for (BadDBPath As String) I get an error.

Here's the code

Sub FixBadAOIndex(badDBPath As String)
' <BadDBPath> is the path to the corrupt database.
Dim dbBad As DAO.Database
Dim tdf As DAO.TableDef
Dim ix As DAO.Index

Set dbBad = DBEngine.OpenDatabase(badDBPath)
dbBad.Execute "DELETE FROM MSysAccessObjects " & _
"WHERE ([ID] Is Null) OR ([Data] Is Null)", _
dbFailOnError
Set tdf = dbBad.TableDefs("MSysAccessObjects")
Set ix = tdf.CreateIndex("AOIndex")
With ix
.Fields.Append .CreateField("ID")
.Primary = True
End With
tdf.Indexes.Append ix
Set tdf = Nothing
dbBad.Close
Set dbBad = Nothing
End Sub

Sorry for asking, but please could you substitute my path correctly into the code or give me some tips??

Thanks very much for your help.

Dan
 
It just doesn't recognise the syntax, saying compile error and highligting the first line in red. I'm not sure whether to include brackets, quotation marks etc, so I asked if somebody would so kind as to substitute it for me?

Dan
 
Check that you have a reference to the Microsoft DAO 3.x Object Library. I guess you backed-up before trying this?
 
how are you "running" the code? from a button? in the debugger?

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top