?
Solved

Code that allows for 3 actions on a YesNoCancel MsgBox without redisplaying the alert

Posted on 2012-08-27
3
Medium Priority
?
325 Views
Last Modified: 2012-08-29
I'm feeling kind of brain dead on this one.

    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbCancel Then
    Exit Sub
    Else
    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbNo Then
    GoTohere
    Else
    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbYes Then
    GoTothere
    Else
    End If
    End If
    End If

Open in new window

This obviously re-displays the alert two more times unless you choose vbCancel.

So how do I write it?

Thanks,
John
0
Comment
Question by:gabrielPennyback
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 38339316
Dim intResponse as Integer

intResponse = MsgBox "Are you sure you want to process one incident only?", vbYesNoCancel

Select Case intResponse
    Case vbYes
        GoTohere
    Case vbNo
        GoTohere
    Case Else
        Exit Sub
End Select

Open in new window

0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 38346960
Awesome, thanks MartinLiss. Just one little typo in line 3. I need to add the parentheses
intResponse = MsgBox ("Are you sure you want to process one incident only?", vbYesNoCancel)

Thanks,
John
0
 
LVL 50

Expert Comment

by:Martin Liss
ID: 38346983
Yes, I typed that directly into the post and forgot the parentheses. In any case you're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2012
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question