Autoexec opposite...

QUINABA

Board Regular
Joined
Jul 18, 2002
Messages
127
Hello,

Is there such a thing as an Autoexec opposite, that would perform macros on exit? I'd like to delete some temporary tables that I've created upon exiting.

Any help would be greatly appreciated.

Thanks.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I believe that you can create a macro called

Autoexit

that executes on close of the database.
 
Upvote 0
I have used two solutions in the past.

1) Have a main form that opens when the database starts(ie Switchboard). On this form have a button which has the action Application.Quit to quit access. Then on the form's OnClose event run your code to clean-up.

2) The other comes from MS KB article # 210297 - Detect User Idle Time or Inactivity in Access 2000. This event opens a hidden form that runs in the background. In this case it checks to see if the user has been inactive and closes the db after a threshold has been reached.

You could modify and add in your table cleanup code before the database is closed. Also, you could again implement the Onclose Event to clean-up.

I like this approach as you will get the added benefit of having users out of the db when they aren't using it. In addition, the form is hidden so you won't have users messing with it.

HTH,
CT
 
Upvote 0
It should also be noted that running procedures during an application's quitting is considered bad practice as these procedure's wouldn't trigger during, say, a power failure, or the dreaded Ctl-Alt-Del and you could really do some damamge to your data/objects. A work-around to this is to either find a way to incorporate your procedures while the db is open or to have your procedures trigger during the On Open event of the database/Startup form.
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top