Msgbox is unresponsive

wrekless

Registered User.
Local time
Today, 22:55
Joined
Jun 1, 2000
Messages
31
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).]
 
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.
 
Thanks, it worked to perfection.
smile.gif
 

Users who are viewing this thread

Back
Top Bottom