Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - CompactDatabase.mdb (advanced)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)

CompactDatabase.mdb (advanced)

 Post Reply Post Reply
Message Reverse Sort Order
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 20 Feb 2008
Status: Offline
Points: 249
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: CompactDatabase.mdb (advanced)
    Posted: 01 Aug 2008 at 7:16am

Please consider donating $1 per sample downloaded, find out why here.


This sample illustrates how to compact the current database programmatically.  It  assumes that the tables reside locally.  (To compact a Back-end database, see my sample "CompactBackEndDB.mdb".) 

1) Create a new, temporary database
2) Copy several pre-created forms, macros and modules to this temp database
3) Close database and launch temporary database with the /x switch which initiates the compact process.
4) After compacting is done, close temp database and relaunch main database

This can be used to safely duplicate the buggy "Compact on Close" feature of Access 2000, because it makes a back-up of the database before compacting it.  If anything goes wrong, you can easily recover the uncompacted database.
Access 97 (46 KB):
Access 2000 DAO (105 KB):

Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down