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

Sunday, March 31, 2013

MsgBox Arguments


MS Access: MsgBox Arguments

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. Therefore, you must accurately select the buttons for your MsgBox. Below is a table that lists all of your MsgBox options.

Applies To

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

Arguments

The arguments for MsgBox are as follows:
ConstantValueDescription
vbOkOnly0Displays 1 button - OK (default value)
vbOkCancel1Displays 2 buttons - OK and Cancel
vbAbortRetryIgnore2Displays 3 buttons - Abort, Retry, Ignore
vbYesNoCancel3Displays 3 buttons - Yes, No, and Cancel
vbYesNo4Displays 2 buttons - Yes and No
vbRetryCancel5Displays 2 buttons - Retry and Cancel
vbCritical16Displays a critical message
vbQuestion32Displays a question
vbExclamation48Displays a warning message
vbInformation64Displays an information message
vbDefaultButton10Displays 1 button - OK which is the default
vbDefaultButton2256Second button is default
vbDefaultButton3512Third button is default
vbDefaultButton4768Fourth button is default
vbApplicationModal0Displays 1 button - OK. Modal message box for the application.
vbSystemModal4096Displays 1 button - OK. Modal message box for the system.
vbMsgBoxHelpButton16384Displays 2 buttons - OK and Help.
vbMsgBoxSetForeground65536Displays 1 button - OK. Message box window becomes the foreground window.
VbMsgBoxRight524288Displays 1 button - OK. The text message is right aligned.
VbMsgBoxRtlReading1048576Displays 1 button - OK. Used for Hebrew and Arabic systems.

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