ozone
the error code doesnt arise UNTIL you try to insert the record
so before update event wont catch it. Before update allows you manually to inspect the data (with code), and make sure the data appears correct before permitting the update. ie checking ranges or certain values, making sure required fields are completed and so on. You could actually perform a lookup here to see if the item already exists.
the point is that these tests do NOT raise an error.
If you don't test for an error, and just process the update, then the next event is the after update event. The record HAS now been added, and here you may want to tidy up the display, lock/unlock some fields etc, but it is too late now to stop the update.
Now in-between the before update, and after update, the update actually occurs. Access does this for you, so you still get the before update, but if the update fails, you get an error raised, and no after update. In this case, Access reports the error with its own error message, and no error number.
So you can intercept the access error, by using the error event and depending on the error number, replace it with a tailor made error message of your own. This is what you have done. The problem is often finding the error numbers that access is using.
If you use an error event then this will catch ANY form error.
On the other hand, if you do something that knowingly may cause an erorr, you can generally trap this in code, and resolve the particular issue with a error handler