Why I cannot delete all records contains duplicated record? I only able to delete half of them.
Code:Private Sub Command1_Click() On Error Resume Next Set db = New ADODB.Connection db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DBMS.mdb;Persist Security Info=False" Set rst = New ADODB.Recordset rst.Open "Select * from A", db, adOpenDynamic, adLockOptimistic Dim strDupName As String, strSaveName As String If rst.BOF And rst.EOF Then MsgBox "No records to process" Else MsgBox "DUPLICATE FOUND DELETE" rst.MoveFirst Do Until rst.EOF strDupName = rst.Fields(0) & rst.Fields(1) & rst.Fields(2) If strDupName = strSaveName Then rst.Delete Else strSaveName = rst.Fields(0) & rst.Fields(1) & rst.Fields(2) End If rst.MoveNext Loop Set rst = Nothing Set db = Nothing End If End Sub




Reply With Quote