Solved

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

706 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

18 Experts available now in Live!

Get 1:1 Help Now