Option to cancel action on msgbox

  • Thread starter Thread starter Thorson
  • Start date Start date
T

Thorson

I just created a real simple message box for a form, but the code only gives
the user the option to select "OK" is there a way to give the user the option
to select "OK" or "Cancel" and have "Cancel" cancel the rest of the action?

Here is my code:

Private Sub DeleteFemaleAAEPD_Click()
MsgBox "You are about to delete and update all current Female AAA EPD Records"
DoCmd.RunMacro "mcrAAAEPDUpdateRecords"
End Sub
 
Thank you
--
Thorson


Ken Snell said:
Private Sub DeleteFemaleAAEPD_Click()
Dim intReply As Integer
intReply = MsgBox("You are about to delete and update all current Female AAA
EPD Records", vbOKCancel, "Confirm Update?")
If intReply = vbOK Then
DoCmd.RunMacro "mcrAAAEPDUpdateRecords"
Else
MsgBox "The update has been cancelled.", vbOK, "Action Cancelled"
End If
End Sub

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
Thank you!
--
Thorson


fredg said:
Change your MsgBox into a function MsgBox().

If MsgBox("You are about to delete and update all current Female AAA
EPD Records", vbQuestion + vbOKCancel, "Continue?") = vbOK Then
DoCmd.RunMacro "mcrAAAEPDUpdateRecords"
End If

See VBA help on MsgBox.
 
Back
Top