Full Version: ON OPEN: Copy database over another
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
col
Everyone,

is there a way programically to copy a database over another?
col
I'm trying to use this code to make a backup copy of the database when it opens, but get a permission denied error. Both files exist. I want to overwrite the database_backup.mdb each time the database opens or when specified by the user. please help. thanks.

Function CopyDB()
Dim Location As String
Dim FileName As String
Dim BackupFileName As String

Location = "C:\Program Files\Database"
FileName = "database.mdb"
BackupFileName = "database_backup.mdb"
FileCopy Location & "\" & FileName, Location & "\" & BackupFileName

End Function
r_cubed
Look at the KILL command (which will 'kill' your exisitng backup) BEFORE doing the FileCopy
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.