Hi Scott,
You can do it with a little file juggling:
Sub Test()
' Running this line of code leaves you with your
' original database and a compacted temporary version
' of your original database on drive C:
DBEngine.CompactDatabase "C:\Test.mdb", _
"C:\TestTemp.mdb"
' Delete old backup file if there is one.
If Dir("C:\Test.bak") <> vbNullString Then
Kill "C:\Test.bak"
End If
' Now change the extension of your original database to
' save as a backup file, and rename the compacted temporary
' version of your original database to the name of your original
' database.
Name "C:\Test.mdb" As "C:\Test.bak"
Name "C:\TestTemp.mdb" As "C:\Test.mdb"
End Sub
HTH,
Bob
|