I'm using a msgbox with the vbyesno functionality. Is it possible to have a command performed if yes is selected and a different command if no is selected?
The MsgBox function returns a 6 if the answer from the box is "Yes" and 7 if "No".
Here are the ACCESS Help Return values for the MsgBox:
Constant Value Description
vbOK 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No
Example: If MsgBox("Message Question", vbYesNo, "Msg Title" = 6 then
'Yes answer - Put Yes code here
else
'No answer - Put No code here.
end if
Let me know if you need more assistance. Bob Scriver
Right, but the nicest thing about those constants is that you can use them in your code. Most of the times that I use a msgbox the code structure looks something like this:
if vbYes = msgbox("What's the answer", vbYesNo, "Title" Then
'Do some stuff
else
'Do some other stuff
End if
That way you don't have to remember what number corresponds to what constant.
Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.