?
Solved

Run code when Access Closes

Posted on 2009-04-01
3
Medium Priority
?
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 600 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 400 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 Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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