Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Indiana
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MsgBox vbOKCancel Decisions (Access 97)

    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

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox vbOKCancel Decisions (Access 97)

    Try this:
    <pre>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
    ...</pre>

    Francois

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Indiana
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox vbOKCancel Decisions (Access 97)

    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.

Posting Permissions

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