Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirming That you want to Quit Access

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
I want to know if there is a way when clicking on the upper "X" Button, which is the button to exit the Access Application. If I can prompt the user to type "YES" and only then will it quit Access, Otherwise it will stay in whichever Form or Report he/she is in at the present time.

Any Help on this would be appreciated.
 
Put this code in behind form_unload

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Are you sure you want to close form", vbYesNo) = vbNo Then
DoCmd.CancelEvent
End If
End Sub
 
Hi!

Try this:

Make a form called frmExit(or whatever else you want to call it) and in the Form_Unload event procedure put this line:

If MsgBox("Are you sure you want to quit Access?", vbYesNo) = vbNo Then cancel = True

Now create a macro called autoexec(this name is not optional) and use the command OpenForm. Select frmExit and use the window mode hidden. Now whenever you open the database this window will be open and hidden. When access tries to close the form upon quitting, the message box will appear. If they click no the whole event will be canceled. If they click yes, then Access will go ahead and close.

hth
Jeff Bridgham
 
Disregard my post... I thought you were talking about a form only. Jeff's way will work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top