Compact and Repair Linked Table MDBs

W

Wayfarer

I have an MDB that I use as a front-end for several tables in several
other data-only MDBs. I would like to be able to programmatically
compact and repair these other MDBs from the front-end *without* having
to open each MDB.

Is this possible and, if so, is there an example of how I could do it?

Thanks,
Neill
 
P

Paul

You need to something like this:

1. Retrieve and store the path/filename for the database with the linked
table as parsed from the Connect proprerty
2. Compact the linked database using CompactDatabase to a new file named
comptmp.mdb
3. Kill the old file
4. FileCopy comptmp.mdb to the old file name
5. Kill comptmp.mdb

Note you cannot have any forms or recordsets open on data in the linked
database while compacting.
 
D

Douglas J. Steele

Alternative, rename the old file(s) to something you can use as a backup,
then use CompactDatabase to compact the renamed file to the correct file
name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Paul said:
You need to something like this:

1. Retrieve and store the path/filename for the database with the linked
table as parsed from the Connect proprerty
2. Compact the linked database using CompactDatabase to a new file named
comptmp.mdb
3. Kill the old file
4. FileCopy comptmp.mdb to the old file name
5. Kill comptmp.mdb

Note you cannot have any forms or recordsets open on data in the linked
database while compacting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top