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!

Compacting a Database

Status
Not open for further replies.

MarketAn

Technical User
Oct 12, 2000
12
US
I need to automate this procedure. I have a database that is updated daily then Uploaded to my Web Server. The database doubles in size daily and my upload is taking too long. Is there a way I can add a line in my macro to compact the database, once the update is complete? Thank you!
 
I am not sure that I follow you, when you say add a line to your macro, are you implying that the update process and the upload are part of the Macro? Have you tried updating the database on the web server directly? Anyway, the DAO solution copied from VB Help is:

Copies and compacts a closed database, and gives you the option of changing its version, collating order, and encryption. (Microsoft Jet workspaces only).

Syntax

DBEngine.CompactDatabase olddb, newdb, locale, options, password

The CompactDatabase method syntax has these parts.

Part Description
olddb A String that identifies an existing, closed database. It can be a full path and file name, such as "C:\db1.mdb". If the file name has an extension, you must specify it. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1.mdb".
newdb A String that is the file name (and path) of the compacted database that you're creating. You can also specify a network path. You can't use the newdb argument to specify the same database file as olddb.
locale Optional. A Variant that is a string expression that specifies a collating order for creating newdb, as specified in Settings. If you omit this argument, the locale of newdb is the same as olddb.
You can also create a password for newdb by concatenating the password string (starting with ";pwd=") with a constant in the locale argument, like this:
dbLangSpanish & ";pwd=NewPassword"
If you want to use the same locale as olddb (the default value), but specify a new password, simply enter a password string for locale:
";pwd=NewPassword"
options Optional. A constant or combination of constants that indicates one or more options, as specified in Settings. You can combine options by summing the corresponding constants.
password Optional. A Variant that is a string expression containing a password, if the database is password protected. The string ";pwd=" must precede the actual password. If you include a password setting in locale, this setting is ignored.




 
The compact databse cannot be automated (easily) with DAO because DAO requires a new name for the database. I've currently got a routine which renames the DB, kills the orginal file, then renames the copy, but I haven't started using it due to it's risk. (What happens if compact doesn't work and you kill the original ?)

I've heard 2000 has a compact on open option.....

Tyrone Lumley
augerinn@gte.net
 
You can compact an open database using the SendKeys statement

SendKeys ("%(TDC)")

Set this in a module and call it as part of your db shutdown procedure. That way the db for upload will always be compressed.

HTH

Lightning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top