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

Recovering deleted records 1

Status
Not open for further replies.

ei0dk

Technical User
Apr 13, 2000
1
IE
I have just deleted all records in a clients tables(Access 97).&nbsp;&nbsp;As I understand it, the files are not deleted but marked for deletion (as in foxpro).&nbsp;&nbsp;Can they be recalled/recovered or the pointer reset to undo the damage.<br><br>regards
 
<br><br>I don't thing so. There is a setting in Access that sets the prompts (or no prompt) for record deletions. Sorry but your records are gone for good. If you want your program to work this way; to mark records as deleted vs. actual<br>deletion it's up to you, the programmer, to create this action.<br><br>We live and learn. <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
This is a posting I;ve had for some time: I have never needed it because I do daily backups&nbsp;&nbsp;&lt;grin&gt;<br><br>&lt;On Thu, 15 Apr 1999 15:29:51 -0600, &quot;Danny Lesandrini&quot;<br>&lt;<A HREF="mailto:dlesandrini@hotmail.com">dlesandrini@hotmail.com</A>&gt; wrote:<br><br>&lt;Danny,<br><br>&lt;Where were you two days ago when I reallllly needed you !!<br><br>&lt;This is probably the best example of the usefulness of &lt;scanning most<br>&lt;if not all the messages in a UG.<br><br>&lt;BTW - this code is now recorded for future reference (mine &lt;in any case<br>&lt;g&gt;).<br><br>&lt;Sol.<br><br>&gt;Paste the code below into a module, save it and run the function.<br>&gt;<br>&gt;' This module contains simple Visual Basic for Applications function<br>&gt;' that you can use to recover a table deleted from a Microsoft Access<br>&gt;' for Windows 95 and Microsoft Access 97 database under the following<br>&gt;' conditions:<br>&gt;'<br>&gt;' - The database has not been closed since the deletion of the table.<br>&gt;'<br>&gt;' - The database has not been compacted since the deletion of the table.<br>&gt;'<br>&gt;' - The table was deleted using the Microsoft Access user interface.<br>&gt;'<br>&gt;' NOTE: If multiple tables have inadvertently been deleted, this function<br>&gt;' recovers only the last table that was deleted. The other tables are lost.<br>&gt;<br>&gt;<br>&gt;Function UnDeleteTable(Optional strName As String)<br>&gt;<br>&gt;Dim db As Database, strTablename As String<br>&gt;Dim i As Integer, StrSqlString As String<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;If IsMissing(strName) Then strName = &quot;MyUndeletedTable&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Set db = CurrentDb()<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;For i = 0 To db.TableDefs.Count - 1<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;If Left(db.TableDefs(i).Name, 4) = &quot;~tmp&quot; Then<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strTablename = db.TableDefs(i).Name<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StrSqlString = &quot;SELECT DISTINCTROW [&quot; & strTablename & &quot;].* INTO &quot; &<br>&gt;strName & &quot; FROM [&quot; & strTablename & &quot;];&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.SetWarnings False<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.RunSQL StrSqlString<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.SetWarnings True<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;A table has been restored as &quot; & strName, vbOKOnly,<br>&gt;&quot;Restored&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GoTo Exit_undo<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Next i<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;No Recoverable Tables Found&quot;, vbOKOnly, &quot;Not Found&quot;<br>&gt;<br>&gt;Exit_undo:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set db = Nothing<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&gt;Err_undo:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_undo<br>&gt;<br>&gt;End Function<br>&gt;<br>&gt;<br>&gt;--<br>&gt;Danny Lesandrini<br>&gt;<A HREF="mailto:dlesandrini@hotmail.com">dlesandrini@hotmail.com</A><br>&gt;<br>
 
<br>Nice try, but it won't help.&nbsp;&nbsp;The code is for recovering deleted TABLES, not deleted RECORDS.&nbsp;&nbsp;If you delete the table object from the database window, then the code can recover it (if it was the last deleted object and you have not compacted).&nbsp;&nbsp;<br><br>Undeleting records is much trickier, and often impossible (in Acces version 95 and later) due to the lack of redundancy of information.&nbsp;&nbsp;although the data is still present, the problem is that the records are variable in length, as are all tect fields.&nbsp;&nbsp;Without knowing where a record begins or ends, it is not possible to identify its fields - at least not in an automated fashion. <p>Peter Miller<br><a href=mailto:ptek@pksolutions.com>ptek@pksolutions.com</a><br><a href= Solutions Home</a><br>Expert services for all manner of low-level database file format issues<br>
(data recovery, security, meta-consulting, data acquisition, automation)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top