Duplicate Entry error message control

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

Guest

We've all seen this error message when a user or ourselves try and enter a
duplicate value in a field, "The changes you requested to the table were not
successful because they would create duplicate values in the index, primary
key, or relationship..."

I'd like to be able to control this message and how the cursor acts as a
result. Is this possible?

For example, I'd like to prompt the user with a box which actually gives
them a way out, instead of having to close the database in disgust like some
lesser skilled users do. This box would have 2 buttons, the first button
would say OK, the second button would say CANCEL.

Underneath each button, it would explain press OK to edit the duplicate
field (once clicked it would move the cursor to the duplicate field instead
of staying in some unspecified field which tells the user nothing), or press
CANCEL to cancel the record entry attempt. (this would just null & void the
record attempt that was just made and return cursor to the first dialog box)

Any suggestions on what direction I should head or if this is even possible?

Thanks a lot.

-Blenvid
 
This is easy enough... There are various events that can be used to handle
this. The first is the form's BeforeUpdate.

Here you can check the values on your form against the values in your
database to ensure that duplication of unique fields has not occurred. If
duplication has occurred you can put up a message box with OK and Cancel.

In any event, on OK you can redirect the user to the duplicate value for a
change, or on Cancel clear the form and cancel the update.

Other events you can use depending on how you want to handle things are
OnError or AfterUpdate of a text control.
 
Hi Devlin,

Thanks for looking into this for me.

Should I be using a form (that's resized to be smaller) to do this? With the
events you mentioned being assigned to buttons I've drawn?

What is the condition called that I should test for where it is saying the
error message I indicated?

Any assistance with the coding would be much appreciated.

Thanks again!

-Blenvid
 
Back
Top