Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Angry Unanswered: Delete confirmation message not working

    I am using the following to allow the user to confirm a dletion of a customer record, but when they click NO or CANCEL it still says to click OKAY to delete the record...

    What did I do wrong??

    Private Sub DELREC_Click()
    On Error GoTo Err_DELREC_Click
    Dim MsgResult As VbMsgBoxResult

    MsgResult = MsgBox("Are you sure?", vbYesNoCancel, "Confirm Delete of Customer Record")
    If MsgResult = vbYes Then ' Do your delete
    End If

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

    Exit_DELREC_Click:
    Exit Sub

    Err_DELREC_Click:
    MsgBox Err.Description
    Resume Exit_DELREC_Click

    End Sub

  2. #2
    Join Date
    Apr 2003
    Posts
    59
    I am hazy on DoMenuItem but does the following carry out the delete?

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

    If it does then surely your End If is in the wrong place?

  3. #3
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

    Those lines select the record and then delete it. katerpillar's right...move your End If to after those two lines. you should have:
    Code:
    MsgResult = MsgBox("Are you sure?", vbYesNoCancel, "Confirm Delete of Customer Record")
    If MsgResult = vbYes Then ' Do your delete 
        DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
        DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    End If

Posting Permissions

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