D
David Jensen
Hi,
We have a mission critical database that has a table to has become corrupt.
From looking at the table it appears that there are two records that are the
source of the problem. I have no idea how it happened, but it appears that
the two corrupt records have the data in the fields shifted over one field
from where they should be. Since the table is populated via a form, that
doesn't make sense to me, but seeing is believing. We have tried various
methods to delete the two corrupt records but they will not delete, even
though we can delete other records in the table. Compact and repair does
not work. The KB 295334 - ACC2002: Jet compact Utility crashes on the
table. I think that the solution to recover the records from the table
might be from this article on the Access Web:
http://www.mvps.org/access/tables/tbl0018.htm. I have copied it below. The
problem is that I don't know how to actually execute this code. Here is
what I thought I was supposed to do. I pasted the code, just like it is,
into a new module. We changed the following lines . . .
Set OldRes = db.OpenRecordset("tbl_Reservations")
Set NewRes = db.OpenRecordset("tbl_New_Res")
.. . . to correspond to the actual corrupt table and desired new table.
We are unsure of what to do with the following line. . .
NewRes![ResID] = OldRes![ResID]
is [ResID] supposed to correspond to existing fields in the table, or is
this function going to create those fields?
When we tried to compile the code, we got the following message: "Invalid
procedure call or argument".
Would someone please elaborate on the particulars of how to actually execute
this code and what we need to do to make it work (the more detail, the
greater our already great appreciation, as we are clearly not as VB literate
as we should be). The frustration of not knowing what to do with this code
is maddening. I am thankful for the helpful individuals on this newsgroup,
however, as you've been life savers before.
Thanks so much.
--
David Jensen
Change the xyz in my email address to MJ for my real email address. Thanks.
________________________________________________________________
Below is the code from http://www.mvps.org/access/tables/tbl0018.htm
(Q) How can I recover records from a corrupt table?
(A) First, using Access while in the database window, copy the table's
structure only from the corrupt table, if possible. Then using the code
below, copy each individual row from the old table to the new one until it
encounters an error. The error routine displays the error, skips one row,
moves to the next and Resumes at Addit where it continues to move data from
the old table to the new table one row at a time.
' ********* Code Start ***********
' This code was originally written by Norm Chezem
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Norm Chezem
'
Function CopyRes()
Dim db As Database
Dim OldRes As Recordset
Dim NewRes As Recordset
Dim ErrMsg1 As String
Dim RecCount As Long
On Error GoTo err_Proc
Set db = CurrentDb()
Set OldRes = db.OpenRecordset("tbl_Reservations")
Set NewRes = db.OpenRecordset("tbl_New_Res")
RecCount = 0
OldRes.MoveFirst
Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![ResID] = OldRes![ResID]
'CONTINUE COPYING ALL ROWS FROM OLD TBL TO NEW
NewRes.Update
RecCount = RecCount + 1
DoEvents
If RecCount Mod 10000 = 0 then
MsgBox RecCount 'Show progress every 10,000 rows
End If
Loop
MsgBox RecCount 'Show total successful record count
OldRes.Close
NewRes.Close
db.close
Proc_Exit:
Exit Function
Err_Proc:
MsgBox "<Error>" & Error$
OldRes.MoveNext 'Skip this corrupt row
Resume Addit 'Continue at Addit
End Function
' ********* Code End ***********
We have a mission critical database that has a table to has become corrupt.
From looking at the table it appears that there are two records that are the
source of the problem. I have no idea how it happened, but it appears that
the two corrupt records have the data in the fields shifted over one field
from where they should be. Since the table is populated via a form, that
doesn't make sense to me, but seeing is believing. We have tried various
methods to delete the two corrupt records but they will not delete, even
though we can delete other records in the table. Compact and repair does
not work. The KB 295334 - ACC2002: Jet compact Utility crashes on the
table. I think that the solution to recover the records from the table
might be from this article on the Access Web:
http://www.mvps.org/access/tables/tbl0018.htm. I have copied it below. The
problem is that I don't know how to actually execute this code. Here is
what I thought I was supposed to do. I pasted the code, just like it is,
into a new module. We changed the following lines . . .
Set OldRes = db.OpenRecordset("tbl_Reservations")
Set NewRes = db.OpenRecordset("tbl_New_Res")
.. . . to correspond to the actual corrupt table and desired new table.
We are unsure of what to do with the following line. . .
NewRes![ResID] = OldRes![ResID]
is [ResID] supposed to correspond to existing fields in the table, or is
this function going to create those fields?
When we tried to compile the code, we got the following message: "Invalid
procedure call or argument".
Would someone please elaborate on the particulars of how to actually execute
this code and what we need to do to make it work (the more detail, the
greater our already great appreciation, as we are clearly not as VB literate
as we should be). The frustration of not knowing what to do with this code
is maddening. I am thankful for the helpful individuals on this newsgroup,
however, as you've been life savers before.
Thanks so much.
--
David Jensen
Change the xyz in my email address to MJ for my real email address. Thanks.
________________________________________________________________
Below is the code from http://www.mvps.org/access/tables/tbl0018.htm
(Q) How can I recover records from a corrupt table?
(A) First, using Access while in the database window, copy the table's
structure only from the corrupt table, if possible. Then using the code
below, copy each individual row from the old table to the new one until it
encounters an error. The error routine displays the error, skips one row,
moves to the next and Resumes at Addit where it continues to move data from
the old table to the new table one row at a time.
' ********* Code Start ***********
' This code was originally written by Norm Chezem
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Norm Chezem
'
Function CopyRes()
Dim db As Database
Dim OldRes As Recordset
Dim NewRes As Recordset
Dim ErrMsg1 As String
Dim RecCount As Long
On Error GoTo err_Proc
Set db = CurrentDb()
Set OldRes = db.OpenRecordset("tbl_Reservations")
Set NewRes = db.OpenRecordset("tbl_New_Res")
RecCount = 0
OldRes.MoveFirst
Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![ResID] = OldRes![ResID]
'CONTINUE COPYING ALL ROWS FROM OLD TBL TO NEW
NewRes.Update
RecCount = RecCount + 1
DoEvents
If RecCount Mod 10000 = 0 then
MsgBox RecCount 'Show progress every 10,000 rows
End If
Loop
MsgBox RecCount 'Show total successful record count
OldRes.Close
NewRes.Close
db.close
Proc_Exit:
Exit Function
Err_Proc:
MsgBox "<Error>" & Error$
OldRes.MoveNext 'Skip this corrupt row
Resume Addit 'Continue at Addit
End Function
' ********* Code End ***********