Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate Compact and Repair Utility 2

Status
Not open for further replies.

kiwuji

MIS
Apr 9, 2003
16
US
Does anyone know how to automate Compact and Repair utility add-ins? Is there a way to write codes that would automatically execute the compact & repair utility?

Please Help...Thank you
kiwuji
 
You will need to referrence Microsoft Jet and Riplication Objects 2.5 Library.

Code could look like this...
Dim DatabasePath as string
Dim DatabasePath_New as string

DatabasePath = "C:\Program Files\TestDB.mdb"
DatabasePath_New = "C:\Program Files\TestDB1.mdb"
Dim Je as new JRO.JetEngine

Je.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0.;DataSource=" & DataBasePath, "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & DatabasePath_New
 
what about "tools", "option", "general" tab...

Select "compact on close".

Each time you close the table, it will automatically compact.

Will this do? [thumbsup2]
 
Thank you both Creepers and cotton, both method work very good. the only thing i have to upgrade 150 databases :( but it's for a good cause. Thank you again
kiwuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top