'AfterDelete' event ??

J

Jay

I'm having trouble triggering an event procedure after a record is deleted
from a subform.

I'd like the procedure to calculate values based on the subform's records
EXCLUDING the deleted record. However, when I delete an entire record on the
subform, my Form_Delete event procedure does calculations based on the
original recordset and INCLUDES the deleted record.

Any thoughts would be appreciated,
 
K

Klatuu

I think you can resolve this by requerying the subform before you do the
calculation. The deleted record is not yet really deleted, just marked for
deletion in the subform's recordset. The table doesn't know it has been
deleted, yet.
 
J

Jay

Hi Dave -
Thanks for the response. I've tried the Requery approach; it doesn't apply
in this case. I have found a work-around using the AfterDelConfirm event,
but it's not ideal.

'TextBoxSub' is located on the Subform Footer (which is invisible) and it is
a calculated control that sums Cost values for records on the subform.
'TextBoxParent' is an unbound textbox control on the parent form that is
reset programmatically in a variety of event procedures to equal the value in
TextBoxSub. I need to reset it in one more event - when an entire record is
deleted from the subform.

The problem I have found is that a record delete does fire the Form_Delete
event, but the calculated TextBoxSub control doesn't update until after the
Form_Delete event completes... In other words TextBoxSub still holds the
pre-deletion total; using the Form_Delete event procedure to assign that
value to TextBoxParent simply assigns the pre-delete value to TextBoxParent.

The only event that I can get to work is AfterDelConfirm. This event
apparently fires after the record is physically deleted. However, users may
have Confirm Record Changes turned off, in which case, the AfterDelConfirm
event doesn't occur.

Don't knock yourself out on this one; I guess I'll go with the work-around
for now. However, it sure is curious that the Delete event must complete
BEFORE calculated controls are updated. I've tried all kinds of backdoor
approaches (AfterUpdate, Requery, Recalc, Refresh, waiting for Delete event
to trigger the Current event, etc.) and cannot find a solution to what seemto
be a very common problem.
 
K

Klatuu

Thanks for the feedback Jay. I can see I need to do some experimenting with
this for my own knowledge.
 

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

Similar Threads


Top