Sascha Hendel said:
Hello,
accidently I deleted a table in my microsoft access 97
database. I noticed it instantly.
Is there a way to undelete/recover the table?
An answer would be very very helpful for me because I
spent more than two weeks work in this table and missed to
make a backup :-(
Sascha
If you haven't compacted the database, try the following function. I
can't remember if you can expect it to work if you've closed and
reopened the database or not, but it's worth a try:
----- start of code -----
Function UndeleteTable()
Dim db As DAO.Database, strTableName As String
Dim i As Integer, StrSqlString As String
Set db = CurrentDb()
For i = 0 To db.TableDefs.Count - 1
If Left(db.TableDefs(i).Name, 4) = "~tmp" Then
strTableName = db.TableDefs(i).Name
StrSqlString = "SELECT DISTINCTROW [" & strTableName & _
"].* INTO MyUndeletedTable FROM [" & strTableName & "];"
DoCmd.SetWarnings False
DoCmd.RunSQL StrSqlString
DoCmd.SetWarnings True
MsgBox "A table has been restored as MyUndeletedTable", _
vbOKOnly, "Restored"
GoTo Exit_UndeleteTable
End If
Next i
MsgBox "No Recoverable Tables Found", vbOKOnly, "Not Found"
Exit_UndeleteTable:
Set db = Nothing
Exit Function
Err_UndeleteTable:
MsgBox Err.Description
Resume Exit_UndeleteTable
End Function
----- end of code -----