Private Sub Quit_Click()
Dim intResponse As Integer
intResponse = Msgbox("Are you sure you want to quit?",vbYesNoCancel)
Select Case intResponse
Case vbYes
'Docmd.Quit
Case vbNo
'Exit anyway
Case vbCancel
'Cancel
End Select
End Sub
Private Sub Quit_Click()
Dim intResponse As Integer
intResponse = Msgbox("Are you sure you want to quit?",vbYesNoCancel)
Select Case intResponse
Case vbYes
'Docmd.Quit
Case vbNo
'Exit anyway
Case vbCancel
'Cancel
End Select
End Sub
1. Create a form - nothing on it just a form.
2. Save it
3. While in the form is open in Design view, go to the Events tab on the properties dialog and in the Unload event, select the drop down that says [EventProcedure].
4. Click on the ellipsis (...) that appears next to that
5. That will take you to the code window
6. Place this code in the Unload event:
Code:
Dim varResp As Variant
varResp = MsgBox("Are you sure you want to close the program?", vbYesNo, "Close Confirmation")
Select Case varResp
Case vbYes
DoCmd.Quit
Case vbNo
Cancel = True
Exit Sub
End Select
Exit Sub
To set the form as hidden, you would just right click on it in the Database Window and select the HIDDEN checkbox.
To open the form when your program opens, put this code in the On Open event of your main form:
Thanks a lot for your advise. I changed litle bit the code and it works!!!
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Are you sure you want to close the program?", vbYesNo) = vbNo Then
Cancel = True
Else
Exit Sub
End If
End Sub