Simple problem: Id like to procedurally (not globally) suppress the
confirmation dialog for a particular delete query. Intercepting the
"before delete confirm" event doesn't seem to work. See below more
more info.
I have a form button that displays a list of records. The button Click
event FIRST runs a DELETE query which purges the table of old records,
then opens a form to display the remaining good records. Every time it
does this, Access displays a warning confirmation dialog You are
about to run a delete query that will modify data in your table. Are
you sure?
I want to suppress this dialog box, just for this particular
operation.
I DONT want to globally disable Access delete confirmation, so I
dont want to use the Access menu setting (clear the Record Changes
check box under Confirm on the Edit/Find tab of the Options dialog
box, under Options on the Tools menu). I also want the behavior to be
part of the database, & behave this way when distributed to other
users.
I wanted to intercept the BeforeDelConfirm event as part of the click
event code, but it appears to be only useful within a form's events.
So, I removed the DELETE query from the button click event code and
moved it to the FORM_LOAD event of the form that the button launches.
I then added a Form_BeforeDelConfirm event to the form, and it uses
the Response = acDataErrContinue option.
However, when I click the button, the delete query confirmation still
appears, and the Form_BeforeDelConfirm event never seems to fire.
For what its worth, heres the complete form code:
--------------------
Option Compare Database
Private Sub Form_Load()
DoCmd.OpenQuery ("qryDeleteOld")
End Sub
Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Hooray, this works! Delete this record?", vbOKCancel) =
vbCancel Then
Cancel = True
End If
End Sub
--------------------- |