natasha said:
How can I compact db programaticallY?
I am running code in the db:delete records in the table
and return autonumber to 1.Can I compact db
programatically in my current open db?
thanks
I don't believe it's possible to compact the currently open db
programatically. Unless you have a split db and the BE is what you want to
compact. Then you would use code like the following:
'First rename the original, can't compact to same name
'strDB is the db to compact's name
'Strip off ".mdb"
strDBBackup = Left(strDB, Len(strDB) - 4)
'Add "Backup.mdb" to name
strDBBackup = strDBBackup & "Backup.mdb"
'Rename DB to Backup name
Name strDB As strDBBackup
DBEngine.CompactDatabase strDBBackup, strDB
'Assuming you've implemented an error handler, and all has gone well, delete
the original
'If there is an error then this line won't be executed and you'll still have
the backup
Kill strDBBackup