>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).
>>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).