Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-03-21
3
Medium Priority
?
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 2000 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: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

704 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