Hi -
I have a function in the backend of my database that when executed is supposed to create a backup in the location that I have specified on our network drive. The code was working well until I put a password on the back end database. Now when it runs, I receive a run-time error #70 "permission denied". I assume it is because I am not specifying the password anywhere? I am just not sure where it should go if that is the case? Or if maybe the password is not the issue and there is something else wrong with the code?
Any help is appreciated. Thanks!
I have a function in the backend of my database that when executed is supposed to create a backup in the location that I have specified on our network drive. The code was working well until I put a password on the back end database. Now when it runs, I receive a run-time error #70 "permission denied". I assume it is because I am not specifying the password anywhere? I am just not sure where it should go if that is the case? Or if maybe the password is not the issue and there is something else wrong with the code?
Any help is appreciated. Thanks!
Code:
Option Compare Database
Public Function db_backup()
Dim sourceFile As String, destinationFile As String
Dim aFSO As Variant
Dim path As String, name As String
sourceFile = CurrentProject.FullName
path = CurrentProject.path
name = CurrentProject.name
destinationFile = "\\Documents\Database_v1_BackUp.accdb"
If Dir(destinationFile) <> "" Then
Kill destinationFile
End If
If Dir(destinationFile) = "" Then
Set aFSO = CreateObject("scripting.filesystemobject")
aFSO.copyfile sourceFile, desinationfile, True
End If
End Function