Close command or the like either, if you have any data-bound controls to that database on your form; you have to unload the form. As a second point, note that the CompactDatabase code requires that you specify a target file for the compacted database--this target can't be an existing file so it can't be the source database. Apparently there's a timing issue here, too. I may have had the same error when I attempted to Delete or Update records, but I definately had it with Insert. The only way around this that I've found is to create a menu form which calls either the Maintenance form where the record deletion code lives or a Compact Database form where the Compaction code goes. This is easy to do so it won't take much work to test it.