• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

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?
0
darrellread
Asked:
darrellread
  • 4
  • 3
1 Solution
 
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
 
darrellreadAuthor Commented:
i hope it works
0
 
jbrugmanCommented:
if you don't get it to work, tell, so i can help implementate.
0
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
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

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now