How trap invalid delete in continuous form ?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
Using the ON DELETE event solved my problem.
Then I checked for the related records with DLOOKUP, and if found, cancelled
the event.
 
Back
Top