Yes of course you can it's simple but a REALLY BIG mistake.
You could use something like
Dim strOldPathName As String
Dim strNewPathName As String
myfile = Dir("C:\Path to DB here.mdb")
If myfile <> "" Then
Kill "C:\Path to BackUpName here.mdb"
strOldPathName = "C:\Path to DB here.mdb"
strNewPathName = "Some Drive:\BackupName.mdb"
strOldPathName, strNewPathName
Else
strOldPathName = "C:\Path to DB here.mdb"
strNewPathName = "Some Drice:\BackupName.mdb"
End If
BUT DON'T
You can't backup or compact a DB that someone may be working on or isn't
open in exclusive mode (well you "can" but it's not reliable - and thats not
the point of a backup). Check out the MS knowledge base for a load of
reasons to NOT do this.
The best way is to either
Use a DB that is set up to backup all your other DB's and run the code from
there
Use scheluder (the best and simplest way to do this)
Use this method on the MVP site
http://www.mvps.org/access/modules/mdl0045.htm