error on indexed field

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

I have a multi-field index on a table and would like to
customize the error message on form to replace the
default "changes....were not successful
because...duplicate values in the index......" since this
doesn't help users know the real issue or how to respond.
How can I find out what this particular error number is
since other errors might also happen?
 
You can trap this error with the Error event of your form.
It's easy enough to create the error, and see DataErr is 3022.

Other common DataErr values include:
3201 related record required
2113 wrong data type.
3024 file missing (e.g. network connection broke).

To get more specific information on what was the duplicated value, you could
write some code in the BeforeUpdate event of the Form. Since
Form_BeforeUpdate fires *before* the attempt to save the record, you can
investigate anything that is likely to go wrong before the DataErr is
generated.
 
Back
Top