delete confirmation mysteriously disappeared

AlanS

Registered User.
Local time
Today, 13:33
Joined
Mar 23, 2001
Messages
292
In my Access 97 application, the normal deletion confirmation message ("You are about to delete ...") no longer appears when I delete a record using a particular form bound to a particular table. Since there is now no deletion confirmation message displayed, the AfterDelConfirm event procedure is not run, and that's causing major problems for the application. Up until today, the message appeared, the event procedure ran, and everything worked as it should.

Does anyone know how this could change all of a sudden, and what I might do to correct it? Note that I have already verified the following:

1. Under Tools, Options, Edit/Find, all the options (including Record Changes) are enabled in the Confirm area.
2. When I delete a record from the same table directly in Datasheet view, and when I delete a record from another table (whether via a bound form or directly from the table in Datasheet view), the normal delete confirmation message appears.
3. Warning dialogs have not been disabled in this form. In addition, even when I run a macro which explicitly enables warning dialogs, the problem persists.
 
Have you tried all the usual, compile and save all modules, compact, import everything into a new blank db?
 
Rich:

Yes I have, but the result is the same.
 
I would perform a search through all modules to see if I wouldn't have left somewhere a DoCmd.SetWarnings disabling warning messages for some specific action, and not immediatly followed by another SetWarnings statement to re-enable messages.

(yes, I read about you macro, but who knows?)
 
I finally figured out what was happening - part of the problem is less than complete documentation of event dependencies in the Access help screens.

According to the Access help screens, when you delete a record on a form, the following events fire in this order: Delete, BeforeDelConfirm, AfterDelConfirm. What it DOESN'T say is that between the Delete and BeforeDelConfirm events, the Current event also fires (probably because the record is actually deleted to a holding buffer at that point, which causes it to disappear from the form, which causes the next record to appear, and Current normally fires whenever a different record is displayed), and that the Current event fires again after the AfterDelConfirm event.

In my application, the Current event procedure sets the values for two text box controls but only for new records. Also, the AfterDelConfirm event procedure does certain housekeeping necessary to keep other forms synchronized with the form where the deletion is happening.

What I noticed was that when I deleted a record, the Delete event always fired, but the BeforeDelConfirm and AfterDelConfirm events sometimes did and sometimes did not, which caused synchronization problems and invalid Null references. What I finally discovered is that when you use the Current event (which fires after Delete but before BeforeDelConfirm) to set control values, it has the effect of aborting the pending BeforeDelConfirm and AfterDelConfirm events. In this case, since I was only setting the control values when a new record was displayed, the problem only occurred when I was deleting the last record (in all other cases the next record displayed would be an existing record).

I worked around this problem by setting up a module-level Boolean variable to use as a flag. That variable is set to True in the form's Load event procedure, to False in the Delete event procedure, and back to True at the end of the AfterDelConfirm event procedure. The control setting functions of the Current event procedure are now conditional on the variable being True, which it is not the first time Current fires, but it is the second. So, the controls get set as they need to for a new record, but only after all the other events are finished.
 

Users who are viewing this thread

Back
Top Bottom