Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access: Capture values when record is deleted from subform

When I delete data in a Form or SubForm, I want to catch the deleted record in the BeforeDelConfirm event. I know it is possible to get the data out of the "delete buffer" to use it for something else.

I do not want to use the Delete event. I know it is possible to get the data from there before it is actually deleted in the Recordset, but I want it on the BeforeDelConfirm event out of the "delete" buffer.

I know it is possible because I made it a few years ago, but I do not find the right code and did not found it in several Google sessions.

like image 257
DeBugOfen Avatar asked Apr 16 '14 22:04

DeBugOfen


1 Answers

Allen Browne points out that the Delete event fires for each record, but BeforeDelConfirm fires once -- even if multiple records are selected for deletion. So there is no opportunity to capture those values.

The value of the deleted record(s) is not available in BeforeDelConfirm. Use the Delete event to get the value.

It is possible to delete several records at once, e.g. if you select multiple records in a continuous form or datasheet. The Delete event fires once for each record, and the value is available each time. Then the BeforeDelConfirm and AfterDelConfirm events fire once for all deletes, but the values are not available at that time. You therefore need to write the value(s) of the deleted record(s) to an array or temp table in the Delete event if you want to read them in the BeforeDelConfirm event.

He provides an example: http://members.iinet.net.au/~allenbrowne/AppAudit.html

like image 136
Smandoli Avatar answered Oct 14 '22 11:10

Smandoli