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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Similar to Autoexec Macro, but for closing

Status
Not open for further replies.

cmitsys

Technical User
Oct 31, 2003
14
0
0
Hi, Does anybody know of a way to have MS Access open a form when you try to close the application.

Simular to when you use autoexec when you start the application, but I need one for when you are exiting the application instead.
 
I'm not sure if there is a macro to do this, but you can create a procedure that does this for you, and call the procedure every time that the user tries to quit the app. I use a Quit button:

Private Sub cmdQuit_Click()

Dim response As VbMsgBoxResult

response = MsgBox("Are you sure you want to quit?", vbYesNo)

If response = vbYes Then
DoCmd.Quit
Else
Exit Sub
End If

End Sub

You can do your form stuff where I do the MsgBox stuff.



-Gary
 
Hi!

The trick here, is to have a form open at all time as long as the application is running. You might use your main switchboard, have an invisible form or whatever. Point is to use this forms on unload event, to check whether it's ok to close. And then, open the form you want. There you might set a variable to "yes, no it's ok to close" (aka true;-)).

Process of getting there, most of the steps are provided by this faq faq702-1870.

Post back if anything is unclear.

The nice thing with this method, is that it traps for CTRL+F4, ALT+F4, CTRL+W, hitting the x button - every way of closing the database.

HTH Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top