make a column in the table called: MARK (len = 1 string)
make a query, qsDupeList, to show the data and the MARK field, sort the query on the dupe fld: "[your Dupe Fld]", item1...
paste the code into a module.
run the code below to mark the duplicates.
the code will the marked ones if theres a dupe.
then delete them with a query where [MARK] = 'D'
usage:
RemoveDuplicates "qsDupeList", "DupeFld","Mark"
put this code into a module
Code:
Public Sub RemoveDuplicates(ByVal pvQry, ByVal pvDupeFld, ByVal pvMarkFld)
'pvQry = query name
'pvDupeFld = field with duplicate values
'pvMarkFld = 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) & ""
If vCurrDup <> "" Then
'-----------------------
'MARK THE DUPES...
'-----------------------
If vPrevDup = vCurrDup Then 'found a dupe so mark it
.Edit
.Fields(pvMarkFld) = "D"
.Update
End If
End If
vPrevDup = vCurrDup
.MoveNext
Wend
End With
DoCmd.Hourglass false
Set qdf = Nothing
Set rst = Nothing
Set db = Nothing
Exit Sub
ErrRemove:
MsgBox Err.Description, , mkCLASSNAME & "::RemoveDuplicates():" & Err
End Sub