Copying password protected VBA Access DB...permission denied

jpetway

New member
Local time
Today, 10:15
Joined
Sep 27, 2023
Messages
2
I am copying a password protected backend database with the code below. I get the following error "permission denied". The code works perfectly if the database is not password protected. What am I missing to get password protected backends to copy?

Public Sub Test0()
Dim SourceFile, DestinationFile
SourceFile = CurrentProject.Path & "\" & "2 DB BEs\Champ 22_sales_be.accdb" ' Define source file name.
DestinationFile = CurrentProject.Path & "\" & "2 DB BEs\Champ 22_sales_beeee.accdb" ' Define target file name.
FileCopy SourceFile, DestinationFile
End Sub
 
Similar code works for me.
Permission denied usually indicates the file is already open

BTW Your Dim line defines each variable as a variant
Use Dim SourceFile As String , DestinationFile As String
 

Users who are viewing this thread

Back
Top Bottom