J
Jaybird
This code seems to be looping through the same record over and over. Any
idea what's wrong with it?
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("Order Entry")
Set NewRes = db.OpenRecordset("Order Entry2")
RecCount = 0
OldRes.MoveFirst
Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![Order Number] = OldRes![Order Number]
'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 "<This is the error!>" & (Chr(13)) & (Chr(13)) & Error$ & (Chr(13))
& (Chr(13)) & NewRes![Order Number], vbOKCancel
If Response = "OK" Then Resume
If Response = "Cancel" Then Exit Function
OldRes.MoveNext 'Skip this corrupt row
Resume Addit 'Continue at Addit
End Function
idea what's wrong with it?
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("Order Entry")
Set NewRes = db.OpenRecordset("Order Entry2")
RecCount = 0
OldRes.MoveFirst
Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![Order Number] = OldRes![Order Number]
'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 "<This is the error!>" & (Chr(13)) & (Chr(13)) & Error$ & (Chr(13))
& (Chr(13)) & NewRes![Order Number], vbOKCancel
If Response = "OK" Then Resume
If Response = "Cancel" Then Exit Function
OldRes.MoveNext 'Skip this corrupt row
Resume Addit 'Continue at Addit
End Function