I am trying to use Access 2007 to take a copy of a user selected file and copy it to a specific location on a public share using the code below. However, when I run it, I get a Run-time error '70': Permission denied.
I've used this code in both Access v2003 and v2010 without any issue. I know for a fact that the account I am logged in with on the computer I am using has local admin rights. I have also tried re-pointing the code to a folder on the local hard drive, but I get the same result.
I need this function to work regardless of whether the end user has local admin rights or not. Is there a way to correct this? If not, is there any other code that would work instead that anyone is willing to share?
Dim Db As Database
Dim old_RST As Recordset
Set Db = CurrentDb
Set old_RST = Db.OpenRecordset("tbl_OldValues", dbOpenDynaset)
Dim image1_Src As String
Dim image1_Dst As String
Dim fname1 As String
Dim pfname1 As String
Dim picpath As String
Set fs = CreateObject("Scripting.FileSystemObject")
picpath = old_RST![docPath]
image1_Src = Me.Form1 '(This is a text box on the form holding the source location)
image1_Dst = picpath '(This is the default destination location saved in a settings table)
fs.CopyFile image1_Src, image1_Dst 'This is line that errors!
fname1 = FileNameFromPath(Me.Form1)
pfname1 = picpath & fname1