Renaming a database via VB code

  • Thread starter Thread starter Virgil
  • Start date Start date
V

Virgil

Running DBEngine.CompactDatabase in VB requires you to
supply a new name for the compacted database. I'd like to
rename that compacted copy to the prior name. I know I
can do a Kill to delete the old copy, but renaming the new
copy is a mystery.
 
Virgil said:
Running DBEngine.CompactDatabase in VB requires you to
supply a new name for the compacted database. I'd like to
rename that compacted copy to the prior name. I know I
can do a Kill to delete the old copy, but renaming the new
copy is a mystery.

Look up "Name Statement" in VBA Help:

Name OldfilePath&Name As NewfilePath&Name
 
On my website (see sig below) is a small sample database called
"CompactDatabase.mdb" which does just that, including re-naming the file.
 
Back
Top