View Full Version : Msgbox is unresponsive


wrekless
07-17-2000, 11:29 AM
On my form, I have a button that, when clicked, has an if structure in it:

If MsgBox(strMsg, vbYesNoCancel, "Warning!") = vbYes Then
Forms![Changes Pending].SetFocus
Exit Sub
ElseIf MsgBox(strMsg, vbYesNoCancel, "Warning!") = vbNo Then
stDocName = "QRY Add Revision Data"
[DoCmd.OpenQuery] 'basically opens a query
Exit Sub
ElseIf MsgBox(strMsg, vbYesNoCancel, "Warning!") = vbCancel Then
Exit Sub
End If


My problem is that upon clicking a no or a cancel in the MSGBOX the first time, nothing happens. The msgbox just flashes and comes back. If I click three times, the action takes place. (No, runs my query; Cancel, exits the sub).

It's not looped, anybody know why it does this?

thanx

[This message has been edited by wrekless (edited 07-17-2000).]

[This message has been edited by wrekless (edited 07-17-2000).]

Travis
07-17-2000, 11:35 AM
Your right it's not looped but look a little closer you keep asking the question over again. Try asking the question only once as follows:

Dim response as Variant

response = MsgBox strMsg, vbYesNoCancel, "Warning!"
if response = vbYes Then
Forms![Changes Pending].SetFocus
Exit Sub
ElseIf response = vbNo Then
stDocName = "QRY Add Revision Data"
[DoCmd.OpenQuery] 'basically opens a query
Exit Sub
ElseIf response = vbCancel Then
Exit Sub
End If

Notice that the question is only asked once, thus you will only need to answer it once.

wrekless
07-17-2000, 11:47 AM
Thanks, it worked to perfection. http://www.access-programmers.co.uk/ubb/smile.gif