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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Recovery

Status
Not open for further replies.

FatherOf3

Technical User
Mar 14, 2006
6
US
I receive the following error when trying to open up an Access Database:

This database is in an unexpected state: Microsoft Office Access can't open it.
This database has been converted from a prior version of Microsoft Office Access by using the DAO CompactDatabase method instead of the Convert Database command on the Tools menu (Database Utilities submenu). This has left the database in a partially converted state.
If you have a copy of the database in its original format, use the Convert Database command on the Tools menu (Database Utilities submenu) to convert it. If the original database is no longer available, create a new database and import your tables and queries to perserve your data. Your other database objects can't be recovered.




I have tried to import the tables and queries but I receive the same error. I need help trying to recover the database.

Thanks,

chad



 
There was some code in one of the links that advised how to import the tables and querys from the corrupt database. The code is below:

Option Compare Database

Sub RecoverCorruptDB()
Dim dbCorrupt As DAO.Database
Dim dbCurrent As DAO.Database
Dim td As DAO.TableDef
Dim tdNew As DAO.TableDef
Dim fld As DAO.Field
Dim fldNew As DAO.Field
Dim ind As DAO.Index
Dim indNew As DAO.Index
Dim qd As DAO.QueryDef
Dim qdNew As DAO.QueryDef
Dim strDBPath As String
Dim strQry As String


'Replace the path below to the path of the corrupted database


strDBPath = "C:\EasyLenderMortgageProd.mdb"
On Error Resume Next
Set dbCurrent = CurrentDb
Set dbCorrupt = OpenDatabase(strDBPath)
For Each td In dbCorrupt.TableDefs
If Left(td.Name, 4) <> "MSys" Then
strQry = "SELECT * INTO [" & td.Name & "] FROM [" & td.Name & "] IN '" & dbCorrupt.Name & "'"
dbCurrent.Execute strQry, dbFailOnError
dbCurrent.TableDefs.Refresh
Set tdNew = dbCurrent.TableDefs(td.Name)


'Recreate the indexes on the table


For Each ind In td.Indexes
Set indNew = tdNew.CreateIndex(ind.Name)
For Each fld In ind.Fields
Set fldNew = indNew.CreateField(fld.Name)
indNew.Fields.Append fldNew
Next
indNew.Primary = ind.Primary
indNew.Unique = ind.Unique
indNew.IgnoreNulls = ind.IgnoreNulls
tdNew.Indexes.Append indNew
tdNew.Indexes.Refresh
Next
End If
Next


'Recreate the queries


For Each qd In dbCorrupt.QueryDefs
If Left(qd.Name, 4) <> "~sq_" Then
Set qdNew = dbCurrent.CreateQueryDef(qd.Name, qd.SQL)
End If
Next
dbCorrupt.Close
Application.RefreshDatabaseWindow


MsgBox "Procedure Complete."
End Sub



When I try this code the dbFailOnError comes back with a return code of 128. Also the qd.SQL comes back with: could not read definitions; no read definitions permission for table.

No security was put on this database so I don't understand where it is getting the permissions problem.

Thanks,
Chad
 
security is always active, but when not "enforced" you login as admin with an admin account and a blank password. I believe that the message refers to on of the system (hidden) tables.

Have you tried decompiling your DB?
Code:
"C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE" "C:\path_to_thedatabase.mdb" /decompile

where office 11 is my office 2003 installation, could be different with yours.

Also, are you trying all these suggestions on a backup? or still the one & only copy.....?
 
forgot to mention that /decompile is a commandline option...
 
What version was the database before conversion? For example, was it an Access 97 database that got converted to Access 2000?
 
easyit: I tried the decompile already and I receive the error that the database is in an unexpected state. I am trying all of the suggestions on a backup of the corrupted database.

BBaggins: The database version was 2002-2003 prior to this problem. The problem happened when I did a Compact and Repair.

 
I...don't understand the converting part, did you go back to 2000 or 97? If not, how did the compacting happen> Because you cannot compact the current db by vba code (except by sendkeys or equivalent menu/keys selection).

Did you start dao code from another DB?

Can you connect to the db thru dao/ado from another db? Open exclusivaly? open with shift key down?
 
I didn't try to compact via vba code. I opened up MS Access and went to Tools/Database Utilities and selected Compact/Repair and then selected the database.

I have tried to get the tables and queries by using another database and I cannot connect. I have tried to open exclusively and that does not work either.

 
What he's saying is that the error message he's getting has nothing to do with the actual problem. I'm glad to see you've looked at everything on the FAQ; unfortunately I don't think you've got much hope.

I assume you've tried the trick of opening a new database (e.g. db1.mdb) and attempted to import everything from the old database? Also I assume you've tried to use the JetCompact utility to do a compact/repair?

If so, I don't think there's much hope left. If you seriously need the data, consider a ($$$) data recovery specialist--the FAQ mentions a few. Otherwise...I think you already know.
 
Still: can you connect thru VBA ADO/DAO? Or open with shiftkey down?
 
Yes, I have tried VBA ADO to connect. I tried holding the Shift Key down. Neither worked.

I think it is a lost cause.

Thanks for everyones help.

Chad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top