I am trying to delete all duplicate records in a table. I tried the following code but every time I get to the first duplicate number it deletes the duplicate then ends the code. I know it must be a simple omition but I am cross eyed looking at this code. I'm sure someone can see what I am missing.
Thanks.
Function DelDups()
Dim strNumber As String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rst = db.OpenRecordset("flkpNumbers", dbOpenDynaset)
Do Until rst.EOF
strNumber = rst("NumT")
Do Until rst.EOF
rst.FindNext "[NumT] = '" & strNumber & "'"
If Not rst.NoMatch Then
rst.Delete
MsgBox "You Have Deleted The Duplicate Number " & strNumber & " !", vbOKOnly + vbInformation, "Update Process"
Else
Exit Do
End If
Loop
rst.MoveNext
Loop
MsgBox "You Have Deleted All Duplicate Numbers!", vbOKOnly + vbInformation, "Update Process"
DoCmd.Hourglass False
End Function
Thanks.
Function DelDups()
Dim strNumber As String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rst = db.OpenRecordset("flkpNumbers", dbOpenDynaset)
Do Until rst.EOF
strNumber = rst("NumT")
Do Until rst.EOF
rst.FindNext "[NumT] = '" & strNumber & "'"
If Not rst.NoMatch Then
rst.Delete
MsgBox "You Have Deleted The Duplicate Number " & strNumber & " !", vbOKOnly + vbInformation, "Update Process"
Else
Exit Do
End If
Loop
rst.MoveNext
Loop
MsgBox "You Have Deleted All Duplicate Numbers!", vbOKOnly + vbInformation, "Update Process"
DoCmd.Hourglass False
End Function