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
 

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