MsgBox help

buddythebest

Registered User.
Local time
Today, 15:18
Joined
Mar 31, 2006
Messages
32
How can I let a message box with a Yes or No choice to actually cancel the event when "No" is chosen

Code:
MsgBox "Are you sure you want to cancel this sale?", vbYesNo

This is the first line of an OnClick even for a delete button.... How can I actually let there be a different action for pressing the "No" button of the message box in the form... because with the above code ... yes or no choices are just there for kicks!!
In other words, how can I let different actions be based on buttons of a message box which I have created?

Thanks, I would appreciate any help :D
 
Last edited:
Oh lol I just found this website, I think it will be sufficient for what I want.... but I thought I should share it here in case someone else has the same problem

http://gregmaxey.mvps.org/Custom_MsgBox.htm







Ok now I get it, thanks to the website. I used a Select Case statement... and it worked :D This is what I wrote in my code:
Code:
Select Case MsgBox("Are you sure you want to cancel this sale?", vbYesNo, "Confirm cancel")
Case vbYes
[I]'Remove warnings for convenience[/I]
DoCmd.SetWarnings False

[I]'Wizard generated code to delete the current record and its related fields[/I]
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

DoCmd.SetWarnings True
Case vbNo
[I]'Do nothing[/I]
End Select

Note for newbies: (I am one of them :o ) If you didn't know, a ' before a line of code eliminates it from being run (in italics in my code above - it turns green in VBA ;))... I use this to add notes to my code so that it can be self-explanatory.


This is funny, I question then answer myself :o
Hope it helps others though.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom