Solved

Run code when Access Closes

Posted on 2009-04-01
3
506 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

19 Experts available now in Live!

Get 1:1 Help Now