I am saving data to Access database via excel VBA through ADODB connection.
I have set Primary key for the field “Name of the person”. Now when a duplicate entry is being saved, it shows an error at line rs.update as Duplicate entry.
I want to put a message box alert through which user will be notified that the name is duplicate entry.
I used the following code:
On error goto endo:


Exit sub
Endo:
Msgbox “ Dupliate entry not allowed”
End sub

The problem is that for any type of error, it is showing the Msgbox “ Dupliate entry not allowed” so I want to make the code in such a way that this msgbox should appear only when there is a duplicate entry.