MsgBox Buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can get my MsgBox to display the buttons using VBA, OK and Cancel. I am
performing a delete and want the MsgBox to confirm or exit the procedure, but
both buttons perform the delete.

Does anyone know what I may be doing wrong????
 
The buttons you choose do nothing on their own. They only return a value so
you will know which button the user selected. You then have to construct
your code to perform the action you want based on the user's selection:


If msgbox("Delete The File", vbOkCancel + vbQuestion) = vbOk then
'code to to the delete
Else
'don't do the delete
End If
 
jdawg said:
I can get my MsgBox to display the buttons using VBA, OK and Cancel.
I am performing a delete and want the MsgBox to confirm or exit the
procedure, but both buttons perform the delete.

Does anyone know what I may be doing wrong????

The buttons being pressed don't have any effect other than to close the
mesage box. It is up to your code to do something different depending on
which button was pressed.

If MsgBox("some text", vbOkCancel) = vbCancel Then
'do one thing
Else
'do some other thing
End if
 
Use the MsgBox() function in an If...Then

If MsgBox("Message", buttonValues) = ??? then

Check help under the MsgBox() for the values returned by the various
buttons.
 
Back
Top