Print Page | Close Window

CompactDatabase.mdb (advanced)

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=377
Printed Date: 20 Nov 2019 at 2:46pm


Topic: CompactDatabase.mdb (advanced)
Posted By: Roger Carlson
Subject: CompactDatabase.mdb (advanced)
Date Posted: 01 Aug 2008 at 7:16am

Please consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm - find out why here .

CompactDatabase.mdb

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".) 

Overview:
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.
 
Download
Access 97 (46 KB):
http://www.rogersaccesslibrary.com/forum/uploads/5/CompactDatabase97.zip - CompactDatabase97.zip
Access 2000 DAO (105 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/CompactDatabase2k.zip - CompactDatabase2k.zip



-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window