How trap invalid delete in continuous form ?

G

Guest

I have a continuous form used to update records in a table. This table is
related (one-to-many) with another table and deletes are not allowed if there
are any related records. When a user attempts to delete a record, a generic
MS Access message appears 'Delete not allowed because related records exist
in table ....'. I'd like to trap this error and generate a more user friendly
message. How?
 
D

Dale Fye

Depends on how you are implementing your delete.

If you have code behind a command button, you can preceed
the delete operation with: On Error Resume Next

Then, right after the line where you perform the deletion,
test to see whether Err.Number <> 0. If it is, then you
can test for the actual value of the error and give a more
user friendly error message.

Don't forget to clear the error before moving on.

HTH
Dale
 
G

Guest

Using the ON DELETE event solved my problem.
Then I checked for the related records with DLOOKUP, and if found, cancelled
the event.
 

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

Top