Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Msgbox constants (97)

    Msgbox constants
    A vbYesNoCancel messagebox has a value of 3. But what does this value represent, just that the button was pressed? Because that

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Msgbox constants (97)

    MsgCox returns 6,7, or 2 for me. Could you show us your code?
    Legare Coleman

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Msgbox constants (97)

    You need to invoke it as a function, setting a variable equal to the resutl. You can then test that result variable to see if Yes, No or Cancel was pressed.
    Wendell

  4. #4
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Msgbox constants (97)

    here's the code:

    Private Sub cmdEmail_Click()

    MsgBox "You are about to submit this subscription information. Are you sure?", vbYesNoCancel, "Email"

    'don't submit email...
    If vbYesNoCancel = 2 Or vbYesNoCancel = 7 Then '6/7/3...
    Exit Sub
    Else
    MsgBox "Email a copy to the subscriber as well?", vbYesNo, "Email"
    End If

    'send email...
    If vbYesNo = 6 Then '6/7...
    'don't submit email if email missing...
    If IsNull(Me.txtEmail) = True Or Me.txtEmail = "" Then
    MsgBox "Fill in the subscriber's email address.", vbCritical, "Error"
    Exit Sub
    End If
    DoCmd.SendObject , , , "PreRegistrations@Satellite.Com", Me.txtEmail, , "Subscriber Pre-Registrations", , True
    Else
    DoCmd.SendObject , , , "PreRegistrations@Satellite.Com", , , "Subscriber Pre-Registrations", , True
    End If
    End Sub

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

    Re: Msgbox constants (97)

    I would try :
    <pre>Private Sub cmdEmail_Click()
    Dim intRespons1 As Integer
    Dim intRespons2 As Integer

    intRespons1 = MsgBox ("You are about to submit this subscription information. " & _
    "Are you sure?", vbYesNoCancel, "Email")

    'don't submit email...
    If intRespons1 = vbNo Or intRespons1 = vbCancel Then '6/7/3...
    Exit Sub
    Else
    IntRespons2 = MsgBox ("Email a copy to the subscriber as well?", vbYesNo, "Email")
    End If

    'send email...
    If intRespons2 = vbYesThen '6/7...
    </pre>

    Francois

  6. #6
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Msgbox constants (97)

    i came up with this, thanks for your help!

    Private Sub cmdEmail_Click()

    Dim intResult As Integer ' yesNoCancel...

    intResult = MsgBox("You are about to submit this subscription information. Are you sure? (Be sure you're connected to the internet and that Outlook is on.)", vbYesNoCancel, "Email")

    'don't submit email...
    If intResult = vbNo Or intResult = vbCancel Then '6/7/3...
    Exit Sub
    Else
    intResult = MsgBox("Email a copy to the subscriber as well?", vbYesNo, "Email")
    End If

    'send email...
    If intResult = vbYes Then '6/7...
    'don't submit email if email missing...
    If IsNull(Me.txtEmail) = True Or Me.txtEmail = "" Then
    MsgBox "Fill in the subscriber's email address.", vbCritical, "Error"
    Me.txtEmail.SetFocus
    Exit Sub
    End If
    DoCmd.SendObject , , , "PreRegistrations@Satellite.Com", Me.txtEmail, , "Subscriber Pre-Registrations", , True
    Else
    DoCmd.SendObject , , , "PreRegistrations@Satellite.Com", , , "Subscriber Pre-Registrations", , True
    End If
    End Sub

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Msgbox constants (97)

    I see you finally found out how to test for vbYes, vbNo, etc. Don't even think about the actual values returned (6,7,etc.).

    An alternative would be:

    Select Case MsgBox ("... message...", vbYesNoCancel)
    Case vbYes
    ...
    Case vbNo
    ...
    Case vbCancel
    ...
    end select
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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