Compact & Repair

C

Chefjay22

Hello. I have a MS Access application with a front-end mde and back-end mdb
file. I need to be able to write a script or something that will initiate a
Compact & Repair on the back-end DB file that contains all the data. When
Compact & Repair is initiated on the front-end it of course does not compact
the back-end database. Any ideas? Thanks!
 
K

Klatuu

Here is the basics. I would suggest some good error handling so you don't
loose your database if there is an error

If Dir("\\SomeServe\SomeFolder\MyDatabase.ldb") <> vbNullString Then
MsgBox "Database is in use and cannot be compacted"
Else
strFullPath = "\\SomeServe\SomeFolder\MyDatabase.mdb"
strTmpPath = Replace(strFullPath, ".mdb", "_TMP.mdb")
DBEngine.CompactDatabase strFullPath, strTmpPath
Kill strFullPath
Name strTmpPath As strFullPath
End IF
 

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