View Full Version : You cannot add or change a record


hbrems
01-22-2008, 06:07 AM
You cannot add or change a record because a record is required in <table>.

Simple question (simple answer too I hope). How can I trap this referential integrity error?

I would like to create a more user friendly message.

rainman89
01-22-2008, 06:24 AM
try trapping error 3201

i believe that is the code for that error

hbrems
01-23-2008, 01:42 AM
try trapping error 3201

i believe that is the code for that error

Either that's not the correct err.number or I'm doing something wrong...

At what stage do you suggest I trap this error? I tried:

- form unload
- form close

In both case the error message still pooped up. My aim is to trap when somebody tries to exit the form by:

- clicking a custom close button
- clicking 'x' on the form
- clicking 'x' in top right corner (which closes Access completely)
- choosing file > exit

Kind regards,
Hans B.

hbrems
01-24-2008, 07:02 AM
Anyone? :(

hbrems
01-25-2008, 06:39 AM
Ok,

so I found out how to trap the messages. I use the on error event:

Instead of


select case err.number


I needed


select case DataErr


This allows me to display my custom message. The only thing I need now is to know how to suppress the original message.

Kind regards,
Hans B.

hbrems
01-25-2008, 06:52 AM
Nevermind:

Response = acDataErrContinue