Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

delete button

nabilahnabilah Member Posts: 16
can all of you help me on how to code the delete button.because i want to make an alert box to make a confirmation for deleting record.my problem is,i don't want an access alert box.this because once i click on the delete button first it will come my alert box and the secod time alert box from access come out.how can i code just to appear my alert box but the delete button is still well function.

Comments

  • dokken2dokken2 Member Posts: 532
    : can all of you help me on how to code the delete button.because i want to make an alert box to make a confirmation for deleting record.my problem is,i don't want an access alert box.this because once i click on the delete button first it will come my alert box and the secod time alert box from access come out.how can i code just to appear my alert box but the delete button is still well function.
    :

    [code]
    On Error GoTo erh

    If MsgBox("Are you sure?", vbYesNo, "Delete record") = vbYes Then
    'TURN OFF ACCESS MESSAGES
    DoCmd.SetWarnings False
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    End If

    xit:
    'TURN MESSAGES ON
    DoCmd.SetWarnings True
    Exit Sub

    erh:
    MsgBox Err.Description
    Resume xit
    [/code]
  • nabilahnabilah Member Posts: 16
    : : can all of you help me on how to code the delete button.because i want to make an alert box to make a confirmation for deleting record.my problem is,i don't want an access alert box.this because once i click on the delete button first it will come my alert box and the secod time alert box from access come out.how can i code just to appear my alert box but the delete button is still well function.
    : :
    :
    : [code]
    : On Error GoTo erh
    :
    : If MsgBox("Are you sure?", vbYesNo, "Delete record") = vbYes Then
    : 'TURN OFF ACCESS MESSAGES
    : DoCmd.SetWarnings False
    : DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    : DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    : End If
    :
    : xit:
    : 'TURN MESSAGES ON
    : DoCmd.SetWarnings True
    : Exit Sub
    :
    : erh:
    : MsgBox Err.Description
    : Resume xit
    : [/code]
    :

    Thanks dokken2.it's really work!

  • splansingsplansing Member Posts: 140
    : : : can all of you help me on how to code the delete button.because i want to make an alert box to make a confirmation for deleting record.my problem is,i don't want an access alert box.this because once i click on the delete button first it will come my alert box and the secod time alert box from access come out.how can i code just to appear my alert box but the delete button is still well function.
    : : :
    : :
    : : [code]
    : : On Error GoTo erh
    : :
    : : If MsgBox("Are you sure?", vbYesNo, "Delete record") = vbYes Then
    : : 'TURN OFF ACCESS MESSAGES
    : : DoCmd.SetWarnings False
    : : DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    : : DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    : : End If
    : :
    : : xit:
    : : 'TURN MESSAGES ON
    : : DoCmd.SetWarnings True
    : : Exit Sub
    : :
    : : erh:
    : : MsgBox Err.Description
    : : Resume xit
    : : [/code]
    : :
    :
    : Thanks dokken2.it's really work!
    :
    :
    Quick question: why would you write an error routine that does what Access already does by default (stop and display an error message)?
  • dokken2dokken2 Member Posts: 532
    : : : : can all of you help me on how to code the delete button.because i want to make an alert box to make a confirmation for deleting record.my problem is,i don't want an access alert box.this because once i click on the delete button first it will come my alert box and the secod time alert box from access come out.how can i code just to appear my alert box but the delete button is still well function.
    : : : :
    : : :
    : : : [code]
    : : : On Error GoTo erh
    : : :
    : : : If MsgBox("Are you sure?", vbYesNo, "Delete record") = vbYes Then
    : : : 'TURN OFF ACCESS MESSAGES
    : : : DoCmd.SetWarnings False
    : : : DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    : : : DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    : : : End If
    : : :
    : : : xit:
    : : : 'TURN MESSAGES ON
    : : : DoCmd.SetWarnings True
    : : : Exit Sub
    : : :
    : : : erh:
    : : : MsgBox Err.Description
    : : : Resume xit
    : : : [/code]
    : : :
    : :
    : : Thanks dokken2.it's really work!
    : :
    : :
    : Quick question: why would you write an error routine that does what Access already does by default (stop and display an error message)?
    :

    Two reasons, primarily to trap any error and resume to the 'xit' label to assert that the access system messages are turned back on.
    Secondly, you may want to include more descriptive errors than access provides. And there should be a procedure name included with the error message to help with any debugging, ie: MsgBox Err.Description, vbCritical, "My-procedure-name" [otherwise, how do you know where the error occurred?]
Sign In or Register to comment.