mike_2881
06-03-2003, 05:07 PM
I've created an application for a customer w/ Access as the Database. When the user clicks "Backup" I want the database copied to another location. Here is the code I currently have:
FileCopy "C:\My Documents\Programming\Bennett Auto Rebuilders\Database.mdb", "C:\Bennett Backups\Database.mdb"
I'm getting a run time error '70', Permission Denied.
I'm guessing that I need to close the database file first. Is there a simple command that will close the database before I run the FileCopy command?
Any help would be greatly appreciated.
iowahawk43
06-03-2003, 07:22 PM
I've created an application for a customer w/ Access as the Database. When the user clicks "Backup" I want the database copied to another location. Here is the code I currently have:
FileCopy "C:\My Documents\Programming\Bennett Auto Rebuilders\Database.mdb", "C:\Bennett Backups\Database.mdb"
I'm getting a run time error '70', Permission Denied.
I'm guessing that I need to close the database file first. Is there a simple command that will close the database before I run the FileCopy command?
Any help would be greatly appreciated.
Hey again...I recognize that code! This tells me that your application has the connection to the database still open.
MyDb.Close ' this breaks your connection, replace MyDB with your database variable.
Good practice to also add...
Set MyDb = Nothing
Then go ahead with your filecopy.
mike_2881
06-03-2003, 08:35 PM
I owe you my life and a beer. Thank you.
mike_2881
06-03-2003, 08:44 PM
Below is my code. I'm getting an error saying Invalid Qualifyer when I set mydb = "C:\My Documents\Programming\Bennett Auto Rebuilders\Database.mdb". What am I doing wrong?
Private Sub mnuBackupRunBackup_Click()
Dim mydb As String
mydb = "C:\My Documents\Programming\Bennett Auto Rebuilders\Database.mdb"
mydb.Close
Set mydb = Nothing
FileCopy "C:\My Documents\Programming\Bennett Auto Rebuilders\Database.mdb", "C:\Bennett Backups\Database.mdb"
End Sub