MsgBox (VBA beginner)

dl41001

Registered User.
Local time
Today, 13:03
Joined
Apr 18, 2001
Messages
17
How do I write codes for a MsgBox with vbOKCancel? This is what I want: when I click Cancel, nothing happens. When I hit OK, exit db.
Pls help.
Thank you very much.
 
Hi,

Unfortunately you do not state where you are putting the code so I've assumed you coding a BeforeUpdate event on a form. With that in mind try out this code:

Dim Response As Integer
Dim strMessage As String
Dim strTitle As String

strMessage = "Type your message between these quotes"
strTitle = "Enter a title for your msgbox"

Response = MsgBox(strMessage, vbOKCancel, strTitle)

If Response = vbOK Then 'User chose OK
DoCmd.Quit
Else
Cancel = True
Response = acDataErrContinue
End If
 
Thanks, Robert. It's really helpful.
 

Users who are viewing this thread

Back
Top Bottom