Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Msgbox values

Status
Not open for further replies.

jspence

Technical User
Mar 5, 2003
3
US
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.

Jeremy ==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top