Copying password protected VBA Access DB...permission denied (1 Viewer)

jpetway

New member
Local time
Today, 07:53
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
 

isladogs

MVP / VIP
Local time
Today, 12:53
Joined
Jan 14, 2017
Messages
18,225
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

Top Bottom