Access: How to run code before file close (apposite of AutoExec)?
I'd like to do some clean-up of temporary tables whenever the user closes the Access file. Is there a way to do this, maybe like the AutoExec macro does for opening, but preferably in VBA?
TIA!
Dennis
Microsoft Access
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
OK, thanks. It's a bit more involved than I would have guessed, but shouldn't be a problem.
Re
D
Jim Dettman (EE MVE)
Note that you can cancel the close of Access by using Cancel = True in the OnUnload event if you find anything you don't like.
Say the user has left forms or reports open other than a switchboard/menu form.
Use the OnClose event for clean-up once you've shut everything down you want in the OnUnload.
Jim.
Jim Dettman (EE MVE)
By the way, that form is a nice place to store things as well, such as a user login name. Or things like a company name and info.
You can do that to avoid having to lookup data all the time.
It's also a great way to keep a persistent connection open to a backend, which if JET/ACE based, can give you a pretty big performance boost (depends on how your app works now).
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Side note ... this is a long standing request for an On Application Close event (et al). It is now under consideration by the Access Product Team ... per access.uservoice.com
Re
D