Times of India Tech: Latest IT, telecom, Internet, BPO news and updates

Sunday, March 31, 2013

MsgBox Return Values


MS Access: MsgBox Return Values

The MsgBox function is one of the most commonly used functions within Access. It is a method of interacting with the user during a session.

Applies To

  • Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Return Values

The return values for MsgBox are as follows:
ConstantValueDescription
vbOK1Value signifies that the OK button was pressed
vbCancel2Value signifies that the Cancel button was pressed
vbAbort3Value signifies that the Abort button was pressed
vbRetry4Value signifies that the Retry button was pressed
vbIgnore5Value signifies that the Ignore button was pressed
vbYes6Value signifies that the Yes button was pressed
vbNo7Value signifies that the No button was pressed

For Example

Here is an example of how you can use a MsgBox.
Dim LResponse As Integer

LResponse = MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
   {...statements...}
Else
   {...statements...}
End If
You've declared a variable called LResponse that stores the result from the MsgBox function. If the user clicks on the Yes button, LResponse will contain the vbYes value and if the user clicks on the No button, LResponse will contain the vbNo value.

No comments:

Post a Comment