• MsgBox vbOKCancel Decisions (Access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » MsgBox vbOKCancel Decisions (Access 97)

    Author
    Topic
    #368801

    Within a form I give the user the ability to print a “cleaned up” copy of the record, however, if they press the put, and then choose not to complete the operation, then I want them to be able to cancel out of the sub. I should add that if the user choose OK, then all of the printing activity is completed for the particular record without the actual “clean verison of the form” opening up (to the users eyes). Basically they get the message box, press OK, the record prints and everything is completed. However, when I select CANCEL, using the code set below, the record still prints off. It’s as if the CANCEL button action is not recognized. I am trying to use more of the MsgBox, vb actions versus always creating little custom dialog forms. Thanks for the help.

    DoCmd.Echo False, “”
    MsgBox “Do You wish to Print a PaySheet for this Training?”, vbOKCancel

    If MsgBox(vbOKCancel) = vbCancel Then
    Exit Sub

    Else
    DoCmd.OpenForm “frmPaySheet”, acNormal, “”, “”, , acNormal
    DoCmd.GoToControl “Record#”
    DoCmd.FindRecord [Record#], acEntire, False, , True, , True
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.PrintOut acSelection, 1, 1, acHigh, 1
    DoCmd.Close acForm, “frmPaySheet”
    DoCmd.Echo True, “”
    End If

    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #578781

      Try this:

      Dim Answer As Integer
      DoCmd.Echo False, ""
      Answer = MsgBox ("Do You wish to Print a PaySheet for this Training?", vbOKCancel)
      If Answer = vbCancel Then
      Exit Sub
      Else
      ...
      • #578788

        Works great. I did have to insert the

        DoCmd.Echo True, “”

        line in before the Exit Sub or the screen would be frozen. Thanks for the help.

    Viewing 0 reply threads
    Reply To: MsgBox vbOKCancel Decisions (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: