Triggering events just before close of database?

G

GPO

Access 2000 SP3

Is there a way of triggering events that will happen when (or just before) a
database is closed? At the moment my database compacts on close, which is
great, but I have several tables that contain temporary data that can be
deleted (cleaned up) whenever the database is closed. Compacting after the
data temporary is deleted will make things much quicker.

I thought if I could reference the database window
 
G

GPO

I've put a DoCmd.Quit in there, but it closes Access entirely. I just want
to close the particular mdb file that I have open, similar to closing the
database window. I'd be grateful for any suggestions.

Cheers

GPO
 
M

Marshall Barton

GPO said:
I've put a DoCmd.Quit in there, but it closes Access entirely. I just want
to close the particular mdb file that I have open, similar to closing the
database window. I'd be grateful for any suggestions.

You've lost me now. I thought you said the db was already
quiting and you wanted a place to delete the records in
several tables.

Instead of using Quit in the Unload event, why not just use:

db.Execute "DELETE * FROM sometable"

and then let the db continue to close?
 
G

GPO

When you close the database window, the particular mbd file you have open,
closes. DoCmd.Quit does not replicate this, it closes the entire access app
altogether. I want to:
1. Be able to close the mdb file that is open and
2. Leave access open and
3. clean up my tables

at the same time (or near enough to it).

I have everything working the way I want it to (my close button runs all the
db.execute "DELETE..." sql, and then a DoCmd.Quit statement BUT the
DoCmd.Quit statement is not quite what I want because it closes Access
entirely, not just the mdb file. I suppose I'm not getting your "...and then
let the db continue to close?..." statement.

Sorry to confuse you. Hope this is clearer.

Marshall Barton said:
GPO said:
I've put a DoCmd.Quit in there, but it closes Access entirely. I just want
to close the particular mdb file that I have open, similar to closing the
database window. I'd be grateful for any suggestions.

You've lost me now. I thought you said the db was already
quiting and you wanted a place to delete the records in
several tables.

Instead of using Quit in the Unload event, why not just use:

db.Execute "DELETE * FROM sometable"

and then let the db continue to close?
--
Marsh
MVP [MS Access]


"Marshall Barton" wrote
 
R

Rick Brandt

GPO said:
When you close the database window, the particular mbd file you have open,
closes. DoCmd.Quit does not replicate this, it closes the entire access app

Application.CloseCurrentDatabase
 
Joined
Oct 25, 2013
Messages
1
Reaction score
0
A clarification on this. To always capture the close database trigger would you need to disable all means of closing the database other than say, a button or custom menu option? It seems like using the application object would only be effective if you had it attached to an object that can be triggered. My question is - can you use a database level event that will be triggered regardless of how the database is closed (file -exit, clicking on the close X box at top right, etc). My guess is there is no such thing but if there is please let me know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top