Article ID: 209979 - Last Review: June 23, 2005 - Revision: 3.0 ACC2000: How to Compact Databases At a Scheduled TimeThis article was previously published under Q209979 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access database (.mdb). SUMMARY
This article describes a technique that you can use to start compacting one or more databases automatically at a scheduled time. You create a small
database with a table, a form, and a macro. The table stores the names of
the databases that you want to compact. The form contains a procedure in the Timer event that starts compacting the databases whose names are in the
table at the time specified in the procedure. The macro opens the form every time that you open the database.
MORE INFORMATION
The following example uses a Visual Basic procedure to compact one or more
databases and then to quit Microsoft Access when it is finished. You
cannot compact the database that is running the procedure, nor can you
compact any database that you cannot open exclusively. You must have read
and write permissions for the folder where the database that you are compacting resides, and you need enough disk space in that folder to store both the original and the compacted copies of the database. In the example, the code specifies 12:00 midnight as the starting time. To change the starting time, you must edit the code.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
REFERENCESFor more information about the Timer event or the TimerInterval property, click Microsoft Access Help on the Help menu, type timerinterval property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Article Translations
|
Back to the top
