I observe that when I enter an existing primary key value in a form the Microsoft Office Access warning displays saying “the changes you requested to the table were not successful because they would create duplicate values…”.

I want to display a user friendly message in place of this. How do I do that?

2 Spice ups

You can catch it with an On Error statement.

Here is a good place to start.

When I’m looking for a particular error like this, I use the On Error Resume Next then after you try to update the record, then check err.number, if it’s 0 then no errors or if it’s 3022 then it is the error that you mentioned, and you can handle it. If it’s a different error number, you can display and reset.

After you check the error you can reset it by On Error Goto 0 (no handlling) or On Error Goto PROC_ERR or something like that.