Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: Cancelling a Deletion - what Happens

    What events run on deletion?
    what events run when a deletion is cancelled?

    I have some code in the On Current Event of a Form to Show/Hide Controls based on a Checkbox.


    if ckStatus = True Then
    me.txt1.visible = true
    me.txt1.visible = false

    When the form is open this works fine - except when I click a Delete Button
    I am prompted to delete the record - and can if desired

    The problem occurs if I cancel the Deletion

    After cancelling the deletion, the form hides txt1 - even though the checkbox is checked.

    If someone knows the events that happen on deletion, and cancelling a deletion I should be able to chase the issue down. I alreay tried the On Activate event with no luck...

    Thanks - AB

  2. #2
    Join Date
    Nov 2003
    Good question. If you really want to know, you can temporarily place a message at the beginning of each event to see which ones actually get fired. For example:

    MsgBox "OnCurrent Event"

    For a work around, you could create a Flag (via variable) that is declared within the declarations section of your form's code module thus making it public to all other subroutines within that code module. In the code event where the deletion code exits, initiate the flag then carry out the deletion. Then in the OnCurrent event, if the flag is set then ignore whatever code.

    Option Compare Database
    Option Explicit
    Dim DeleteFlag as Integer
    Private Sub DeleteButton_Click()
       DeleteFlag = 1
       DoCmd.RunCommand acCmdDeleteRecord
    End Sub
    Private Sub Form_Current()
       If DeleteFlag = 1 Then DeleteFlag = 0: Exit Sub  '(or  Then Don't Do This or whatever)
       'other code here whatever it may be
    End Sub
    Well...something like that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts