Good evening, guys.
Is it possible to fix the error in this code?
Is it possible to fix the error in this code?
Code:
Dim db As DAO.Database
Dim rsSource As DAO.Recordset
Dim rsTarget As DAO.Recordset
Dim intCounter As Integer
Dim intCount As Integer
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rsSource = db.OpenRecordset("tblmastrtow", dbOpenSnapshot, dbReadOnly)
Set rsTarget = db.OpenRecordset("tblmastr", dbOpenTable)
With rsSource
If Not (.BOF And .EOF) Then
.MoveFirst
'add index to table2 for faster searching
rsTarget.Index = "FullName"
End If
Do Until .EOF
If Not IsNull(!FullName) Then
rsTarget.Seek "=", !FullName
If rsTarget.NoMatch Then
'new record
rsTarget.AddNew
rsTarget!FullName = !FullName
Else
'update the record
rsTarget.Edit
End If
rsTarget!Rtb = !Rtb
rsTarget.Update
rsTarget!NumberUpgradeAfter = !NumberUpgradeAfter
rsTarget.Update
rsTarget!DateUpgradeAfter = !DateUpgradeAfter
rsTarget.Update
End If
.MoveNext
intCount = rs.RecordCount
intAnswer = MsgBox("You are about to update " & intCount & " records." & vbCrLf & _
"Do you want to continue?", vbInformation + vbYesNo + vbDefaultButton2, "Confirm Update!")
If intAnswer = vbYes Then
Loop
.Close
End With
Set rsSource = Nothing
rsTarget.Close
Set rsTarget = Nothing
Set db = Nothing
'MsgBox "Complete"
End Sub