Can't get a MsgBox to work

David Ball

Registered User.
Local time
Tomorrow, 06:07
Joined
Aug 9, 2010
Messages
230
Hi,
I can’t get this message box to work:

Private Sub Command18_Click()
Dim Warning As String
Warning = MsgBox "Are you sure?", vbOKCancel, "Delete?"
If Warning = vbCancel Then
Exit Sub
Else
Me.Recordset.Delete
End Sub

I keep getting a message about “Compile error: Expected: end of statement”. The following part goes red:
Warning = MsgBox "Are you sure?", vbOKCancel, "Delete?"
What do I need to change?
Thanks very much
Dave
 
If you want to return a value from a function, the parameter list must be enclosed in parenthesis . . .
Code:
Warning = MsgBox("Are you sure?", vbOKCancel, "Delete?")
MsgBox "But this works!!!", vbOKOnly, "Doesn't return a value"
 
Thank you very much, MarkK
 

Users who are viewing this thread

Back
Top Bottom