Heatshiver
Registered User.
- Local time
- Tomorrow, 03:37
- Joined
- Dec 23, 2011
- Messages
- 263
I want to find duplicate records of one field in a table and delete all but one of the records using VBA.
I was thinking of using: CurrentDb.Execute "DELETE *
but I'm not sure how to put what I want after that.
I did use the Query Wizard and was able to get the duplicate SQL needed:
SELECT First(tblUserID.[UserID]) AS [UserID Field], Count(tblUserID.[UserID]) AS NumberOfDups
FROM tblUserID
GROUP BY tblUserID.[UserID]
HAVING (((Count(tblUserID.[UserID]))>1));
Any help would be much appreciated! Thanks.
I was thinking of using: CurrentDb.Execute "DELETE *
but I'm not sure how to put what I want after that.
I did use the Query Wizard and was able to get the duplicate SQL needed:
SELECT First(tblUserID.[UserID]) AS [UserID Field], Count(tblUserID.[UserID]) AS NumberOfDups
FROM tblUserID
GROUP BY tblUserID.[UserID]
HAVING (((Count(tblUserID.[UserID]))>1));
Any help would be much appreciated! Thanks.