Compact & Repair

  • Thread starter Thread starter Chefjay22
  • Start date Start date
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!
 
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
 
Back
Top