I copied and pasted the code into that last email, and it didn't
come through looking right. I'll try this again, however if it still
looks funny in the email, I'm sure you can copy and paste into your
module and break it apart correctly.
Dim dbOriginal As String
Dim dbCompact As String
Dim dbPath As String
Dim dbTempPath As String
dbOriginal = "Inventory and Cost.mdb" 'Original Database
dbCompact = "Inventory and Cost1.mdb" 'Database to copy too
dbPath = "M:\Databases\" & dbOriginal 'Path of original database
dbTempPath = "M:\Databases\" & dbCompact 'Path of new database
Call DBEngine.CompactDatabase(dbPath, dbTempPath) 'Compact data
DoEvents
Kill dbPath 'Delete original
DoEvents
Name dbTempPath As dbPath 'Rename new database to original name