View Full Version : how do you control actions in a message box?


gino
04-10-2000, 10:54 AM
i got the message to come up as vbRetryCancel. how do you control what happends if user chooses Retry or Cancel.

for example, if user chooses Retry how do you restrict any action being done? also, that goes for Cancel too. how do you make this into one statement.

this is what i got so far.

If (Me![FROM DATE].Value > [TO DATE].Value)Then
Choice = MsgBox "FROM DATE must be before DATE TO!", vbOKOnly

thank you.

R. Hicks
04-10-2000, 04:27 PM
This seems confusing at first, here is an example using you code:

Private Sub SomeEvent_Click()
Dim strMsg As String
Dim strTitle As String
Dim intChoice As Integer
strMsg = "FROM DATE must be before DATE TO!"
strTitle = "Message Box Example"

If (Me![FROM DATE].Value > [TO DATE].Value) Then
intChoice = MsgBox(strMsg, vbYesNo, strTitle)
If intChoice = vbYes Then
'Code here for Yes choice
Else
'Code here if Yes was not chosen
End If
End Sub

Maybe by examining line by line you will understand the coding. Also the result returned by the message box will be an Integer. vbYes is actually the number 6, and vbNo is the number 7. For more information on this, search Access help for "constants, message box".

Good Luck,
RDH