snowmman99
Technical User
I have a problem and can not figure it out. I have duplicates in one column and a second column with data but located below the duplicate records with no duplicate records to tie it in. The duplicate records are above the criteria for deletion. I would like to delete this criteria from the table. I have tried to match duplicate records and look for the criteria and set it to yes.
This is what i have so far.
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Tbl_out")
Set rs2 = db.OpenRecordset("TblMFOEDLimport")
If rs1.RecordCount = 0 Then Exit Sub
rs1.MoveFirst
Do Until rs1.EOF
If rs2.RecordCount = 0 Then Exit Sub
rs2.MoveFirst
Do Until rs2.EOF
If rs1![Docno] = rs2![I-docno] And rs2![I-Remarks] = "*PT ORD*" Then
rs2.Edit
rs2("DELETE") = "Yes"
rs2.Update
End If
rs2.MoveNext
Loop
rs1.MoveNext
Loop
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Sub
This is what i have so far.
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Tbl_out")
Set rs2 = db.OpenRecordset("TblMFOEDLimport")
If rs1.RecordCount = 0 Then Exit Sub
rs1.MoveFirst
Do Until rs1.EOF
If rs2.RecordCount = 0 Then Exit Sub
rs2.MoveFirst
Do Until rs2.EOF
If rs1![Docno] = rs2![I-docno] And rs2![I-Remarks] = "*PT ORD*" Then
rs2.Edit
rs2("DELETE") = "Yes"
rs2.Update
End If
rs2.MoveNext
Loop
rs1.MoveNext
Loop
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Sub