Prohibiting record deletion

J

John

Hi

When a user presses Delete key to delete a record, I need to check the value
of one of the record fields on the form and depending on the value I need to
allow or not the deletion of record to go ahead. What form event should I
use for this purpose?

Thanks

Regards
 
D

Dirk Goldgar

John said:
Hi

When a user presses Delete key to delete a record, I need to check the
value of one of the record fields on the form and depending on the value I
need to allow or not the deletion of record to go ahead. What form event
should I use for this purpose?


I think it's the form's Delete event that you want for this. You can cancel
it to prevent a record from being deleted, and I think in this event the
current record whose fields you can interrogate is the record that is about
to be deleted. (I'm not sure about the BeforeDelConfirm event, and that
won't not fire if the user has delete confirmations turned off.) Also, if
multiple records are selected for deletion, the Delete event fires for each
of them.
 
D

Dirk Goldgar

Dirk Goldgar said:
I think it's the form's Delete event that you want for this. You can
cancel it to prevent a record from being deleted, and I think in this
event the current record whose fields you can interrogate is the record
that is about to be deleted. (I'm not sure about the BeforeDelConfirm
event, and that won't not fire if the user has delete confirmations turned
off.)

Err, I meant "won't fire", not "won't not fire". And I just checked, and in
the Before DelConfirm event, the values of the form controls are for the
residual record *after* the record(s) have been deleted. So Delete looks
like a better event for your purpose.
 

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