Duplicate Values in Index

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

Guest

How do I trap the "duplicate values in index" error, or is it even trappable?
I want to trap the error, and then display a more user understandable message
and then do an Undo method on the control. Thanks.
 
Hi John,

Instead, write code in the control's BeforeUpdate event procedure which
uses DLookup() to check whether the value already exists. If it does,
display a message box and set Cancel = True.

Putting it in the control's BeforeUpdate event means the user is warned
as soon as the value has been entered, rather than waiting until they
have filled in the entire form. If you want the latter to happen, put
the code in the form's BeforeUpdate event.
 
Thanks. I considered DLookup, but thought maybe it was trappable too. Guess
not! Thanks again.
 
Back
Top