Solved

Copying file Permissions Error using Access 2007 with Non-Admin Account

Posted on 2014-03-21
3
357 Views
Last Modified: 2014-03-21
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
Dim fs

Set fs = CreateObject("Scripting.FileSystemObject")


old_RST.MoveFirst
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

Open in new window

0
Comment
Question by:jmcclosk
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 39945680
FileSystemObject.CopyFile method will fail if destination location has Read Only attribute set.
http://msdn.microsoft.com/en-us/library/e1wf9e7w(v=vs.84).aspx

Have you checked the destination folder(s) for this?
OM Gang

PS - you can do the exact same thing via VB Script so I don't believe it has anything to do with Access or Access version.
0
 

Author Closing Comment

by:jmcclosk
ID: 39945775
Wow!  Even though I have admin rights on the PC granted by my employer, for some reason all my folders show as read-only... even though I can save/copy files to them!  I made the assumption to trust what they told me and didn't investigate far enough before asking the question.  Sorry!  And, thank you!
0
 
LVL 28

Expert Comment

by:omgang
ID: 39946014
No need to be sorry and you're welcome.
OM Gang
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dlookup MSACCESS 5 25
backup programme - VBA 3 24
IIF help, YN field 7 22
VB Script: split files based a intlines flag 27 46
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question