Microsoft Access VBA Macro Programming

(Tina Sui) #1

This example will show a two-button message box (Yes and No). If Yes is clicked, the
following message box will show 6 (vbYes). If No is clicked, the message box will show 7
(vbNo). You can then write your code to specify what will happen according to which action
is taken:


If x = vbYes Then Action 1 Else Action 2


The following table lists the return values for a message box:

Constant Value Description
vbOK 1 OK button clicked
vbCancel 2 Cancel button clicked
vbAbort 3 Abort button clicked
vbRetry 4 Retry button clicked
vbIgnore 5 Ignore button clicked
vbYes 6 Yes button clicked
vbNo 7 No button clicked

Chapter 5: Strings, Functions, and Message Boxes 69

Free download pdf