Ability to put a custom error message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want an error check on a SQL table that looks to make sure not to put a
duplicate record in for the primary keys I set. Access automatically pops up
a message saying that there is a duplicate key record. Is it possible to
pop-up a custom error message rather than the generic message they pop-up.

Thanks in advance,
John
 
You can trap the message and display your own by using the Error event of
the form.

However, all you know at that stage is that a particular DataErr has
occurred, and you don't have details. It may be better, therefore to use
DLookup() in the AfterUpdate event of the control where the duplicate entry
could be found (or in the BeforeUpdate event of the form if the duplicate
consists of multiple fields.)

Avoid performing the DLookup() if nothing actually changed, so that you do
not find the existing record as a duplicate of itself.
 
Back
Top