Update deleted records

  • Thread starter Thread starter Rolf Rosenquist
  • Start date Start date
R

Rolf Rosenquist

I have a subform with order rows inside an order form. The number of each
item sold are subtracted from the stock table. If I delete an item row, the
stock table will be updated so that the number of items will be added back
to the table.

This I have done, by first defining how many and what item is concerned, by
the form's Delete event. Then, with a check of the AfterDeleteConfirm event
status, the number of items go back into stock, if the user confirms the
delete.

This works as intended, but of course, only with one row at a time. How can
I arrange, so that it works also when more than one row is deleted at the
same time?

/ Rolf
 
To track the deletion, you will need a temporary table (or array) that is
populated in the Delete event of the form (fires once for each record), and
then handled in the AfterDelConfirm (fires once for the entire deletion).
There's an example of how to do that in:
Audit Trail - Log changes at the record level
at:
http://members.iinet.net.au/~allenbrowne/AppAudit.html

Presumably you are also handling the edit of an existing record, e.g. where
a user had the quantity as 100, and changes it to 10.

At the end of the day, is it worth the maintenance effort required to store
the quantity on hand? And do you have some periodic self-correcting
mechanism so that the database does not become progressively more
inaccurate? The alternatives may not be suitable for your needs, but you
might like to consider them. Example:
Inventory Control - Quantity On Hand
at:
http://members.iinet.net.au/~allenbrowne/AppInventory.html
 
Very good information and ideas here and on your own pages. It is to big
help for me.
Thanks, I'm very grateful.
/ Rolf
 
Back
Top