MS Access - Error - You don't have permission to modify files in the network location

Hey,

I have a form that have two text boxes as Source and Target. The Source take the source path and the destination textbox copy the file to the destination path.An error pop up at the time of coping file which is run time error says "You don't have permission to modify files in the network location contact Administrator", i am the administrator of the server and the write permission is set to yes. When i manually copy the file it's working but when i try to copy using this VBA code it's giving this error. Although considering the file gets copied but still it's giving up this error, anyone have any idea about that?

As you can see in the image the file is copied as i have write permission. Also when i manually tried to copy its working without any error.Why is this error coming? Due to VBA or due to something else or VBA is not copying instead modifying?


Attach is VBA code if require to  look at :

Private Sub txtSource_Click()
 Dim Dialog      As FileDialog
  
    Dim Selected    As Long
    
    Set Dialog = FileDialog(msoFileDialogFilePicker)
   With Dialog
    .AllowMultiSelect = False
    .InitialFileName = Nz(Me!txtSource.Value)
        .Title = "Select file to copy"
        Selected = .Show
        If Selected <> 0 Then
            Me!txtSource.Value = .SelectedItems.Item(1)
            
        End If
    End With
    
    Cancel = True
End Sub

Private Sub txtTarget_Click()
Dim Dialog As FileDialog
    
    Dim Selected    As Long
    Set Dialog = FileDialog(msoFileDialogSaveAs)
    With Dialog
    .AllowMultiSelect = False
    .InitialFileName = Nz(Me!txtSource.Value)
        .Title = "Name saved file"
         '.InitialFileName = "N:\"
         
        Selected = .Show
        DoCmd.SetWarnings False
        
        If Selected <> 0 Then
         Me!txtTarget.Value = .SelectedItems.Item(1)
         TargetFile = .SelectedItems.Item(1)
            If Not IsNull(Me!txtSource.Value) Then
                 FileCopy Me!txtSource.Value, Me!txtTarget.Value
                 Me.txtTarget = Split(TargetFile, ":")(1)
            End If
           ' Application.FollowHyperlink Me.txtTarget
            
        End If
    End With
    
    Cancel = True
   
End Sub

Open in new window

error.png
LVL 1
WSStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Your code runs (with minor modifications) fine here using a network folder.
Thus, your error is definitely related to lack of permissions for your network folder.

Try to grant full rights to a test folder for "Everyone", and you code will most likely not see the error.

/gustav

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Virat SinghIT & Data Recovery AnalystCommented:
Try to get admin rights if possible. As i guess, getting the admin rights will help your cause
Gustav BrockCIOCommented:
That won't help. Users should at no time run with admin rights.

/gustav
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

WSStudentAuthor Commented:
@Gustav, sorry for taking long, i was trying to add that as a trusted location which is done, but till no i am getting the same error , any idea why?

@Virat, i am the admin of the server.
Gustav BrockCIOCommented:
Please review my first comment.

/gustav
WSStudentAuthor Commented:
@Gustav, that one condition/requirement form user is that other user can't be able to delete files, i can't give full rights to user, i have given them read,write, and execute permission so that they can read and write, the only permission which i haven't given to them is modify as with modify they can delete the files also , but i have given them write permission so this should work, isn't this the thing?
Gustav BrockCIOCommented:
You also need to grant rights for the share.

/gustav
WSStudentAuthor Commented:
how to grant rights? if given rights they will be able to delete also, right?
Gustav BrockCIOCommented:
Only if you grant right to delete.

/gustav
WSStudentAuthor Commented:
with modify , delete grand are automatically checked in permissions in Server.
Gustav BrockCIOCommented:
But if Delete is not granted on the folder itself, users cannot delete.

/gustav
WSStudentAuthor Commented:
how to stop granting on the folder that user can't delete?

As shown in image , how could i stop? the modify operation let user delete, if i turn that off then the error is displayed.
Untitled.png
Gustav BrockCIOCommented:
Right-click folder, Properties, Security.
Unmark Editing (and Full Control).

/gustav
WSStudentAuthor Commented:
done, and now also i can delete files,any idea?
Gustav BrockCIOCommented:
You may have to click Show Advance Options  (at right).
Then you'll see the Delete option:

Permissions.PNG
/gustav
WSStudentAuthor Commented:
yes here exactly the point is. when i turn this delete off, automatically Modify also get off and then i start getting error above. If i turn this delete on ,modify also get turn on and all the things get start working but here is the deal this allow the user to delete also the file which is not required at all.
abc.png
abc1.png
Gustav BrockCIOCommented:
Oh. Problem is, that if you can modify a file, you effectively delete it by overwriting it with a zero byte file.

But try flipping the top combobox to Deny  , remove all marks, and set Delete.

/gustav
WSStudentAuthor Commented:
not working, any other idea?
Gustav BrockCIOCommented:
Sorry, no.

/gustav
WSStudentAuthor Commented:
Thank you Gustav for your guidance. I give modify permission to everyone for the time being as there is no other thing and the code is working fine. Thanks again.
Gustav BrockCIOCommented:
You are welcome!

/gustav
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.