Cancel out of Quit Database

GregSmith

Registered User.
Local time
Today, 17:47
Joined
Feb 22, 2002
Messages
126
I have a command button that once pressed, exit's the database.
I would like it to ask if you are sure and if you say no - it cancels the request to quit. I have tried many solutions but none of them seem to work.
 
Try this on the On_Click of your exit button

Sub comExit On_Click
If MsgBox ("You are about to Exit the Database, Are You Sure?", vbExclamation + vbYesNo + VbDefaultButton2, "Quit Database") = VbYes then
DoCmd.Quit
End If
End Sub

nb vbDefaultButton2 selects No as the default

HTH
 
can't you just do something like this?

Private Sub yourCommandbutton_Click()
Dim intReturn As Integer
intReturn = MsgBox("Do you want to quit application ?", vbYesNo, "Quit ?")
If (intReturn = vbYes) Then
DoCmd.Close
End If

End Sub

Rich
 
This is how I do it:


Private Sub Form_Unload(Cancel As Integer)
Dim intReturn As Integer
intReturn = MsgBox("Do you want to quit application ?", vbYesNo, "Quit ?")
If (intReturn = vbYes) Then
Else
Cancel = True
End If
End Sub

Attach this to the "main" form or switchboard or whatever. When the user closes the main form _OR_ closes the Access window, this event fires.

RichM
 
If MsgBox("Are you sure you want to quit the application?", vbQuestion + vbYesNo, "Application Name Here") = vbYes Then
DoCmd.RunCommand acCmdExit
End If

HTH
 
Useful!

Cool! I think I will use this as well!!

:)
 

Users who are viewing this thread

Back
Top Bottom