Changing the default for OK to Cancel on a MsgBox

J

joelb

I am looking for a way to change the default on this Msgbox from OK to
Cancel when confirming the deletion. Any help would be appreciated....
My code is listed below.

Joel

Private Sub cmdDelete_Click()
On Error GoTo ErrorHandler

Dim strSQL As String

If MsgBox("Are You Sure?", vbOKCancel) = vbOK Then

'Deletes the Item from the PublicationItems table
strSQL = "EXEC spDeletePublicationItemUi @PublicationItemId = " &
fnReplaceSQL(Me.PublicationItemId.Value)
DoCmd.RunSQL (strSQL)

'Refresh Publication Items
Me.Requery

Else
End If

Exit Sub
ErrorHandler:

fnErrorHandler Me.Form.Name, _
vbCrLf _
& "Recordsource: " & Me.Form.RecordSource & vbCrLf _
& "Input Parameters: " & Me.Form.InputParameters & vbCrLf _
& "Active Control: " & Me.ActiveControl.Properties("Name")

End Sub
 
M

Marshall Barton

joelb said:
I am looking for a way to change the default on this Msgbox from OK to
Cancel when confirming the deletion.

Private Sub cmdDelete_Click()
On Error GoTo ErrorHandler

Dim strSQL As String

If MsgBox("Are You Sure?", vbOKCancel) = vbOK Then

'Deletes the Item from the PublicationItems table
strSQL = "EXEC spDeletePublicationItemUi @PublicationItemId = " &
fnReplaceSQL(Me.PublicationItemId.Value)
DoCmd.RunSQL (strSQL)

'Refresh Publication Items
Me.Requery
End If []
End Sub


The way I read Help:
MsgBox("Are You Sure?", vbOKCancel + vbDefaultButton2)
 
J

joelb

Marshall said:
joelb said:
I am looking for a way to change the default on this Msgbox from OK to
Cancel when confirming the deletion.

Private Sub cmdDelete_Click()
On Error GoTo ErrorHandler

Dim strSQL As String

If MsgBox("Are You Sure?", vbOKCancel) = vbOK Then

'Deletes the Item from the PublicationItems table
strSQL = "EXEC spDeletePublicationItemUi @PublicationItemId = " &
fnReplaceSQL(Me.PublicationItemId.Value)
DoCmd.RunSQL (strSQL)

'Refresh Publication Items
Me.Requery
End If []
End Sub


The way I read Help:
MsgBox("Are You Sure?", vbOKCancel + vbDefaultButton2)

Thanks Marsh.... That did the trick.

JoelB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top