ms access

how do you get a message box on the stop button to ask you if you want to quit, and then not quit if you click on no?
darrellreadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jbrugmanCommented:
Private Sub Buttonname_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "continue?"    ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Demo MsgBox"   ' Define title.
Help = "DEMO.HLP"   ' Define Help file.
Ctxt = 1000 ' Define topic
        ' context.
        ' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' User chose Yes.
    MyString = "yes" ' Perform some action.

Else    ' User chose No.
    MyString = "No"    ' Perform some action.
End If
   
End Sub
            
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darrellreadAuthor Commented:
i hope it works
0
jbrugmanCommented:
if you don't get it to work, tell, so i can help implementate.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

darrellreadAuthor Commented:
I have added this code to the button, but it comes up with a help button on the message box, i have no help file, and don't plan to have one so i do not need this in the text box. Below is a copy of the code i have used...

Private Sub Command51_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to quit?"    
Style = vbYesNo  ' Define buttons.
Title = "SEAS Database"   ' Define title.
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then DoCmd.Quit
End Sub

I would also like to know what the Ctxt does.
0
jbrugmanCommented:
Msgbox consists of the following components:

MsgBox prompt,vbYesNo,title,helpfile,context

context = optional, a numeric expression for the help context number.
When not using a help file, don't use context as well.

Greets,
Justus
0
darrellreadAuthor Commented:
cheers this works
0
jbrugmanCommented:
ok :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Hardware

From novice to tech pro — start learning today.