Code: Select all
Option Compare Database
Option Explicit
Sub RemoveDuplicates()
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strTable As String, Y As Long, I As Long
' Set the connection here
Set cnn = CurrentProject.Connection
' Substitute the name of the table here
strTable = "DATI"
rst.Open strTable, cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
Do While Not rst.EOF
DoEvents
'NUMERO
'If DCount("*", strTable, "RAPPORTO=" & rst!RAPPORTO) > 1 Then
'TEST0
If DCount("*", strTable, "NRISCR=" & Chr(34) & rst!NRISCR & Chr(34)) > 1 Then
rst.Delete
I = I + 1
End If
rst.MoveNext
Y = Y + 1
Loop
End Sub
How to?