第一次循环后,“检查”总是为 0,我一直在调试,但仍然找不到原因。任何想法?数据假设有时使“检查”为 0,但并非总是如此。
Private Sub Command12_Click()
Dim db As Database
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Amity")
Set rs2 = db.OpenRecordset("Opportunity")
Set rs3 = db.OpenRecordset("SalesForceDonor")
Set rs4 = db.OpenRecordset("Donor")
While Not rs.EOF
check = 0
While Not rs3.EOF
If rs("Donor_Code") = rs3("Donor_Code") Then
check = 1
End If
rs3.MoveNext
Wend
If check = 0 Then
rs4.AddNew
rs4![Donor_Code] = rs![Donor_Code]
rs4.Update
End If
rs2.AddNew
rs2![Donor_Code] = rs![Donor_Code]
rs2![Donation_name] = rs![Donation_name]
rs2.Update
rs.MoveNext
Wend
rs3.Close
rs4.Close
rs2.Close
rs.Close
End Sub