Error number for duplicate key

G

Guest

I have set up a field as indexed with no duplicates. Does anybody know the error code returned by Access 97 so that I can trap it and return an appropriate message to the user?
 
A

Allen Browne

Use the Error event of the form to trap these values of DataErr:
3022 duplicate index value;
3201 related record required;
2113 wrong data type.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

SHIPP said:
I have set up a field as indexed with no duplicates. Does anybody know the
error code returned by Access 97 so that I can trap it and return an
appropriate message to the user?
 
T

TC

You sometimes have to wonder, where is people's initiative?

step 1 - enter duplicate record;
step 2 - read error message!

:)

TC
 
T

TC

Thanks for the compliment :)

TC


Allen Browne said:
Yes, it is that simple, except that you cannot trap these errors with normal
VBA error handling, and they are not in Err.Number. The Error event of the
form is less obvious to find, and the DataErr values are not listed (AFAIK).

BTW, TC, you have been posting lots of useful answers for people recently.
Thanks.
 
A

Allen Browne

Yes, it is that simple, except that you cannot trap these errors with normal
VBA error handling, and they are not in Err.Number. The Error event of the
form is less obvious to find, and the DataErr values are not listed (AFAIK).

BTW, TC, you have been posting lots of useful answers for people recently.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top