Part II: Programming Microsoft Access
516
FIGURE 13.19
Recalculating a control after a record is deleted
The AfterDelConfirm event procedure returns status information about the deletion. Table
13.3 describes the deletion status values.
TABLE 13.3
Deletion Status Values
Status value Description
acDeleteOK Deletion occurred normally
acDeleteCancel Deletion canceled programmatically
acDeleteUserCancel User canceled deletion
The Status argument for the AfterDelConfirm event procedure can be set to any of these val-
ues within the procedure. For example, if the code in the AfterDelConfirm event procedure
determines that deleting the record may cause problems in the application, the Status argument
should be set to acDeleteCancel:
If <Condition_Indicates_a_Problem> Then
Status = acDeleteCancel
Exit Sub
Else
Status = acDeleteOK
End If
The Status argument is provided to enable your VBA code to override the user’s decision to
delete a record if conditions warrant such an override. In the case that Status is set to
acDeleteCancel, the copy of the record stored in the temporary buffer is restored to the
recordset, and the delete process is terminated. If, on the other hand, Status is set to acDele-
teOK, the deletion proceeds and the temporary buffer is cleared after the user moves to another
record in the recordset.