You cannot add or change a record

hbrems

has no clue...
Local time
Today, 18:20
Joined
Nov 2, 2006
Messages
181
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.
 
try trapping error 3201

i believe that is the code for that error
 
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.
 
Ok,

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

Instead of

Code:
select case err.number

I needed

Code:
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.
 

Users who are viewing this thread

Back
Top Bottom