J
Jaybird
I'm trying to append records from one table to another in order to identify
corrupted records and so that I can use the data in another aplication, but I
can't seem to find a method that works. I've copied and pasted, I've
appended into an empty version of the table, I've looked for corrupted
records manually. Allen Browne, in an earlier post, suggested that the
poster use Norm Chezem's code for moving the records from one table to
another, identifying corrupt data. Here is his code as posted onto 'The
Access Web' site:
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
I went ahead and disambiguated the recordsets to ADO.Recordset, but now it
pukes on this line:
OldRes.MoveNext 'Skip this corrupt row
The message box appears, telling me that it has found the error, but then a
Run Time Error '91' occurs. 'Object variable or with block variable not set'
I know enough about VBA to cause trouble, so I'm having trouble resolving
this issue. If anyone can tell me what I'm doing wrong, I'd appreciate it.
corrupted records and so that I can use the data in another aplication, but I
can't seem to find a method that works. I've copied and pasted, I've
appended into an empty version of the table, I've looked for corrupted
records manually. Allen Browne, in an earlier post, suggested that the
poster use Norm Chezem's code for moving the records from one table to
another, identifying corrupt data. Here is his code as posted onto 'The
Access Web' site:
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
I went ahead and disambiguated the recordsets to ADO.Recordset, but now it
pukes on this line:
OldRes.MoveNext 'Skip this corrupt row
The message box appears, telling me that it has found the error, but then a
Run Time Error '91' occurs. 'Object variable or with block variable not set'
I know enough about VBA to cause trouble, so I'm having trouble resolving
this issue. If anyone can tell me what I'm doing wrong, I'd appreciate it.