Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / May 2008

Tip: Looking for answers? Try searching our database.

Compact and repair under program control?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don Wiss - 17 May 2008 04:20 GMT
I'm doing more putting of data into Access using Excel VBA. After I've done
I like to Compact and Repair the database. I'd like to be able to do this
from VBA. Can I?

Don <www.donwiss.com> (e-mail link at home page bottom).
Chris O'C - 18 May 2008 20:14 GMT
You don't mention what version of Access you're using, but in Access 2002 and
later, the command is:

   CompactRepair SourceFilePath, DestinationFilePath

To use this command in Excel, either set a reference to the Microsoft Access
Object Library or use late binding.

Chris
Microsoft MVP

>I'm doing more putting of data into Access using Excel VBA. After I've done
>I like to Compact and Repair the database. I'd like to be able to do this
>from VBA. Can I?
>
>Don <www.donwiss.com> (e-mail link at home page bottom).
Don Wiss - 18 May 2008 20:41 GMT
>>I'm doing more putting of data into Access using Excel VBA. After I've done
>>I like to Compact and Repair the database. I'd like to be able to do this
>>from VBA. Can I?

>You don't mention what version of Access you're using, but in Access 2002 and
>later, the command is:
[quoted text clipped - 3 lines]
>To use this command in Excel, either set a reference to the Microsoft Access
>Object Library or use late binding.

I'm using Access 2002. Can the Source and Destination file paths be the
same? I connect to the database using DAO 3.6. Normally I would use execute
to execute some command. As I would already be tied to the file I don't see
why I would be giving it a path.

Don <www.donwiss.com> (e-mail link at home page bottom).
Chris O'C - 18 May 2008 20:55 GMT
The source and destination files can't be the same.  You should close the db
before compacting it.  Once it's compacted, delete the source file (or rename
it if you want to test it to be sure it's correct), then rename the
destination file as the source file.  You have to give the path in your code
because Access isn't a very good guesser.  That's why the SourceFilePath and
DestinationFilePath are required parameters for the CompactRepair function.

Chris
Microsoft MVP

>I'm using Access 2002. Can the Source and Destination file paths be the
>same? I connect to the database using DAO 3.6. Normally I would use execute
>to execute some command. As I would already be tied to the file I don't see
>why I would be giving it a path.
>
>Don <www.donwiss.com> (e-mail link at home page bottom).
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.