I am trying to delete duplicate records in an access table using VB. Not a programmer here, but this was one of the codes that I found on the web. I made some modifications to it, but it still did not work for me.
Any assistance is greatly appreciated.
Code:
Public Function DeleteDuplicate()
Dim db As DAO.Database
Dim qdf As QueryDef
Dim strSQL As String
Dim strEmail As String
dteEmail = DMax("[Email]", "tbl_email")
strSQL = "Delete * FROM tbl_email" & _
"WHERE (tbl_email.email)> strEmail"
Set db = CurrentDb
With db
Set qdf = .CreateQueryDef("tmpQuery", strSQL)
DoCmd.OpenQuery "tmpQuery"
.QueryDefs.Delete "tmpQuery"
End With
db.Close
qdf.Close
End Function
Comment