make a col in the table called: MARK
In a query, qsDupeList, add this column:
DupeFld: Iif(item2<item1,item2 & item1,item1 & item2)
uses the code below to mark the duplicates.
sort the query: DupeFld, item1
delete the marked ones if needed.
usage:
RemoveDuplicates "qsDupeList", "DupeFld","Mark"
put this code into a module
Code:
Public Sub RemoveDuplicates(ByVal pvQry, ByVal pvDupeFld, ByVal pvChgFld)
'pvQry = query name
'pvDupeFld = field with duplicate values
'pvChgFld = field to change when duplicate is found
Dim vMsg
Dim db As Database
Dim rst 'As Recordset
Dim qdf As QueryDef
Dim vCurrDup, vPrevDup, vCurrFld, vAddr
'DoCmd.Hourglass True
Set db = CurrentDb
Set qdf = db.QueryDefs(pvQry)
Set rst = qdf.OpenRecordset(dbOpenDynaset)
vPrevDup = "*&%"
With rst
While Not .EOF
vCurrDup = .Fields(pvDupeFld) & ""
vCurrFld = UCase(.Fields(pvFld2Check)) & ""
If vCurrDup <> "" Then
'-----------------------
'MARK THE DUPES...
'-----------------------
If vPrevDup = vCurrDup And vPrevFld = vCurrFld Then 'mark this
.Edit
.Fields(pvChgFld) = "D"
.Update
End If
End If
vPrevDup = vCurrDup
vPrevFld = vCurrFld
.MoveNext
Wend
End With
Set qdf = Nothing
Set rst = Nothing
Set db = Nothing
Exit Sub
ErrRemove:
MsgBox Err.Description, , mkCLASSNAME & "::RemoveDuplicates():" & Err
End Sub