Solved

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

Posted on 2014-03-21
3
355 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

937 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now