Solved

Run code when Access Closes

Posted on 2009-04-01
3
507 Views
Last Modified: 2013-11-27
I would like to run a line of code when my Access program closes.  I would like it to run if the user clicks the "X" at the top right or if they click the exit button on the form I have.  Basically, when the entire application closes I would like to run some code, but I have no idea where the event would go.

Thanks
0
Comment
Question by:adbusbee
3 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 150 total points
ID: 24040632
 The way to do this is to open a hidden form at startup.  When Access closes, this will be the first form to close.  You can place anything you need in the OnClose event of that form.
JimD.
0
 
LVL 14

Assisted Solution

by:pteranodon72
pteranodon72 earned 100 total points
ID: 24040719
You want to create a non-visible startup form (Form design -> Format -> visisble = false) and put the code in the close event of that form.  Set it in Database->Startup. If you already have a startup form specified there, just add

DoCmd.OpenForm "yourRegularStartUp" in the Open Event of the new, non-visible form.

When access quits, it unloads forms in the opposite order they were openned.

The only situation this does not protect against is Ctrl-Alt-Delete -> End Program on Access.

HTH,

pT
0
 

Author Comment

by:adbusbee
ID: 24040791
Worked perfectly.  Good idea, thanks!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now