Changing the default for OK to Cancel on a MsgBox

  • Thread starter Thread starter joelb
  • Start date Start date
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
 
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)
 
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
 
Back
Top