BeforeDelConfirm and AfterDelConfirm not running

M

Marty

Howdy All,

I have a main form/sub form arrangement that includes a "Delete" command
button on the main form. The main form shows one record from one table and
the subform shows related records from a different table. Both recordsets
are contained in one transaction. The delete button is intended to delete
all records in the display. When the command button is clicked, the code
that gets executed is:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If

Before the second "End If" gets executed, the system fires a Delete event
and the Form_Delete procedure gets control. There is no code in this
procedure, but I put it in just to check that it does get trapped by the
debugger. However, neither the BeforeDelConfirm event or the AfterDelConfirm
event gets executed. That is, I can't trap it with the debugger. I do have
code in both procedures but there is no evidence that the code gets executed.
After running the Delete button code, the data on the main form is deleted
but the data on the subform remains. (My code is supposed to delete the
subform data in the BeforeDelConfirm event).

I understand that the Tools ==> Options ==> (Edit/Find tab) ==> "Confirm
Document Deletions" checkbox must be true (checked) or the system suppresses
the BeforeDelConfirm/AfterDelConfirm events. I've checked both in the
Options dialog box and in the code, and the option is true.

The Delete event itself has a Cancel option, and I've checked that the
option is set to false (numeral zero).

I'm pretty stumped. Can anyone think of a circumstance in which Delete
fires but BeforeDelConfirm and AfterDelConfirm will not execute?

Thanks!
Marty
 
D

Dirk Goldgar

Marty said:
I understand that the Tools ==> Options ==> (Edit/Find tab) ==>
"Confirm Document Deletions" checkbox must be true (checked) or the
system suppresses the BeforeDelConfirm/AfterDelConfirm events. I've
checked both in the Options dialog box and in the code, and the
option is true.

That's not the correct option. That option refers to deleting objects
in the database window. According to the help file entry for
"BeforeDelConfirm Event",

<quote>
The BeforeDelConfirm event does not occur and the Delete Confirm dialog
box isn't displayed if you clear the Record Changes check box under
Confirm on the Edit/Find tab of the Options dialog box, available by
clicking Options on the Tools menu.
</quote>

Do you have the Confirm Record Changes check box cleared? It needs to
be checked.
 
M

Marty

Thank You, Dirk,

I used to be able to read English! The Confirm Changes checkbox was,
indeed, cleared. That should clean it up nicely.

Marty
 

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