A
AccessNubee
**Pulling hair out**
I have the following code for an "Exit" button to do three things:
1. If yes is clicked, then save everything and close the application
2. If No is clicked, then prompt to just close the form, if yes, then close
the form if no then leave it open and do nothing
3. If Cancel is clicked, then do nothing and show "Action Cancelled"
I intend to use the same code for all the Exit buttons on my forms so this
is in the Common module
The Yes click works - it will close the application. Great!
I can't figure out why the rest doesn't work. What am I missing?
---------------------------------------------------------------
Public Function cmdExitDatabase()
On Error GoTo Err_cmdExitDatabase
Dim Reply As Variant
Reply = MsgBox("Are you SURE you want to EXIT the database?" & vbNewLine &
"Click No to close this form" & vbNewLine & "Click Yes to EXIT the
Database", vbYesNoCancel, "Exit Confirmation")
Select Case Reply
'If Yes is clicked, then save all and close the application
Case vbYes:
DoCmd.Quit acSaveAllRecords
MsgBox "Have a Great Day!"
Case vbCancel:
'If Cancel is clicked, then Cancel the Action!
MsgBox "Close Cancelled"
'If No is clicked, Just close the form.
Case vbNo:
If MsgBox("Do you want to close the FORM", vbYesNo, "Close
Form?") = vbOK Then
'Close the form
DoCmd.Close
End If
End Select
Exit_cmdExitDatabase:
Exit Function
Err_cmdExitDatabase:
MsgBox Err.Description
Resume Exit_cmdExitDatabase
End Function
-----------------------------------------------------------------
I have the following code for an "Exit" button to do three things:
1. If yes is clicked, then save everything and close the application
2. If No is clicked, then prompt to just close the form, if yes, then close
the form if no then leave it open and do nothing
3. If Cancel is clicked, then do nothing and show "Action Cancelled"
I intend to use the same code for all the Exit buttons on my forms so this
is in the Common module
The Yes click works - it will close the application. Great!
I can't figure out why the rest doesn't work. What am I missing?
---------------------------------------------------------------
Public Function cmdExitDatabase()
On Error GoTo Err_cmdExitDatabase
Dim Reply As Variant
Reply = MsgBox("Are you SURE you want to EXIT the database?" & vbNewLine &
"Click No to close this form" & vbNewLine & "Click Yes to EXIT the
Database", vbYesNoCancel, "Exit Confirmation")
Select Case Reply
'If Yes is clicked, then save all and close the application
Case vbYes:
DoCmd.Quit acSaveAllRecords
MsgBox "Have a Great Day!"
Case vbCancel:
'If Cancel is clicked, then Cancel the Action!
MsgBox "Close Cancelled"
'If No is clicked, Just close the form.
Case vbNo:
If MsgBox("Do you want to close the FORM", vbYesNo, "Close
Form?") = vbOK Then
'Close the form
DoCmd.Close
End If
End Select
Exit_cmdExitDatabase:
Exit Function
Err_cmdExitDatabase:
MsgBox Err.Description
Resume Exit_cmdExitDatabase
End Function
-----------------------------------------------------------------