Help identifying Duplicates

LadyFierce

LadyFierce
Local time
Today, 12:07
Joined
May 13, 2008
Messages
1
Hello, all
I am trying to identify duplicate ids in the ID column by putting "Yes' or "No" in the DUP column that is located on the same table. I have part of the code which I've posted below. The code I have is updating the DUP column with "No". I am missing the part that tells it to look at each previous ID number and if it is the same write yes in the DUP column. Any help will be greatly appreciated. Thanks in advance.

im Mthly_Proposal As DAO.Recordset
Dim db As Database
Dim rst As Recordset
Dim ID As String
Dim i As Integer
Dim strSQL As String
i = ID - 1
Set db = CurrentDb()

strSQL = "SELECT Mthly_Proposal.ID, Mthly_Proposal.Duplicate "
strSQL = strSQL & "FROM Mthly_Proposal "
strSQL = strSQL & "ORDER BY Mthly_Proposal.ID;"
Set rst = db.OpenRecordset("Mthly_Proposal")
If rst.BOF And rst.EOF Then
MsgBox "No records to process"
Else
rst.MoveFirst
Do Until rst.EOF
ID = rst!ID
If ID <> ID Then
rst.Edit
rst!DUP = "Yes"
rst.Update
Else
rst.Edit
rst!DUP = "No"
rst.Update
End If
rst.MoveNext
Loop
Set rst = Nothing
Set db = Nothing
End If

End Sub
 
SELECT ID, Count(ID) FROM Mthly_Proposal GROUP BY ID HAVING Count(ID)>0
This will list duplicate ID's if this is what you are really trying to do.
 

Users who are viewing this thread

Back
Top Bottom