Option to cancel action on msgbox

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
 
T

Thorson

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/
 
T

Thorson

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.
 

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