Autoexecuting code at access exit

hq4ever

New member
Local time
Today, 08:14
Joined
Jun 22, 2003
Messages
5
Hello every one,

What i mean is that i need to run access "Fix & Compress" database function everytime a user exits the DB file its a small desktop database opened only by one user at a time !

i know this is done with DoCmd but i can't get it to work

is it possible that the function to check >



if (db updated )
fix_and_compress(current_db)
else
msgbox "Debug > exit without compress"

quit(access)


help please.
 
If you are using Access 2000 or later, this is an Option you can set in Access. From the MenuBar choose Tools | Options and select the General Tab. Click On Compact on Close. This will Compact and Repair the database whenever it is closed.

If you have any questions, please let me know.
 
Jay,
Several years ago when file compression became popular for HD, I a bad experience with it an lost data that it took a lot of effort to find and restore. What actually goes on when Access compacts a db. Is there risk of corruptin data or even loosing it. Does it slow down searches? If it ahs no effect on speed or data intregrity, why does't Access compact it on the fly.

Just wondering is one should back up the data bdfore compacting.

Thanks
 
Off the record, Access Databases are not the most stable animals on your computer. The way I understand it (and anyone else who wants to can add their two cents) is that Access uses pointers which are stored in memory. This improves Access' performance. Now the bad news. If something happens to the data in memory.... woops. Potential problems can result.

Compacting and repairing should not cause the problem, but if your database is corrupt when you repair and compact and it is beyond the scope of the Compact and Repair utilities, wierd things can happen. Anyone who has worked with MS Access for any length of time knows the horror story.

Best recommendation! Backup often. Our corporate guidelines call for us to backup at least daily.

Compacting and repairing the database can improve performance significantly. So you should do it often.

MS Access doesn't do it all the time because it can be time consuming.

BUT GENERAL RULE BACKUP OFTEN AND COMPACT AND REPAIR OFTEN.
 
ok 10x jaydwest but...

Lets say all i need to do is run a simple VB msgbox that says "thank you for using access" where or how can i achive just that >> access executing my code upon event > access.quit ???
 
edit the code of your exit button to display a msgbox before closing?

or

can't you use the onclose setting for the form you close when the database is closed? (or make it that way)
 
thats not exactly what i had in mind but i guess this will do

thanx anyway MartijnR

m@x.
 

Users who are viewing this thread

Back
Top Bottom