Solved

Run code when Access Closes

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

726 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