Name: aaa.jpg
Views: 11
Size: 34.4 KB
ID: 32573" class="thumbnail" style="float:CONFIG" />
I have used this code in another tables but it's not working on this table.
It will not remove the duplicate
Code:
Sub Remove_Dup_2ATT()
On Error Resume Next
Dim db As DAO.Database, rst As DAO.Recordset
Dim strDupName As String, strSaveName As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("tbl_complete_total_extraBillingcodes_ATT")
If rst.BOF And rst.EOF Then
MsgBox "No records to process"
Else
rst.MoveFirst
Do Until rst.EOF
strDupName = rst.Fields(1)
If strDupName = strSaveName Then
rst.Delete
Else
strSaveName = rst.Fields(1)
End If
rst.MoveNext
Loop
Set rst = Nothing
Set db = Nothing
Call RestoreData
End If
End Sub
Function RestoreData()
On Error Resume Next
Dim strMsg As String
strMsg = "Duplicates Deleted!" & vbCrLf & vbCrLf
strMsg = strMsg & "Click cancel to restore the original table?"
If MsgBox(strMsg, vbOKCancel, "Finished") = vbCancel Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryRefreshBP102_Table"
DoCmd.SetWarnings True
End If
End Function
Access 2016 Pro Plus
Thank you in advance!