[AccessD] Compact DB

paul.hartland at fsmail.net paul.hartland at fsmail.net
Fri May 2 05:28:30 CDT 2003


Ryan,

Not too sure if the following will work, I have a timer program in VB6 I run every night, and here's some basic code I use to copy the database and then compact it...

    Dim MyDate As String
    MyDate = Left(Date, 2) & "_" & Mid(Date, 4, 2) & "_" & Right(Date, 2)
    FileCopy "Dir:\File Name", "Dir:\Backup File Name" & MyDate & ".mdb"

    DBEngine.CompactDatabase "Dir:\Backup Filename" & MyDate & ".mdb", "Dir:\Compacting Name"
    Kill "Dir:\File Name"
    Name "Dir:\Compacting Name" As "Dir:\File Name"


Firstly the code makes a copy of the database along with the date, then it compacts the backup of the database, then kills the original database and renames the compacted DB to whatever the original name was......I compact the backup just in case anything goes wrong, you always have the original database then......

It's from VB6, but I'm sure all these commands work in Access.....


Paul 




From: "Smethurst, Ryan" <ryan.smethurst at bromley.gov.uk>
Date: Fri 02/May/2003 10:15 GMT
To: "'accessd at databaseadvisors.com'" <accessd at databaseadvisors.com>
Subject: [AccessD] Compact DB

---- London Borough of Bromley E-Mail Disclaimer ---- 
"For information about Bromley Council visit our web site
www.bromley.gov.uk" 

"The information contained in this message (including any attachments) is
confidential in that it is intended solely for the use of the recipient to
which it is addressed. If you are not the intended recipient, the use of the
information by disclosure, copying or distribution is prohibited and may be
unlawful." 
---- End of Disclaimer ---- 

Hi Group,

Is it possible to compact a db in code when quitting it?

Thanks
RyanS

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


__________________________________________________________________________
Join Freeserve http://www.freeserve.com/time/

Winner of the 2003 Internet Service Providers' Association awards for Best Unmetered ISP and Best Consumer Application.




More information about the AccessD mailing list