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

WS
WS used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
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
Virat SinghIT & Data Recovery Analyst

Commented:
Try to get admin rights if possible. As i guess, getting the admin rights will help your cause
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
That won't help. Users should at no time run with admin rights.

/gustav
Should you be charging more for 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 using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

WSStudent

Author

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.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Please review my first comment.

/gustav
WSStudent

Author

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?
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You also need to grant rights for the share.

/gustav
WSStudent

Author

Commented:
how to grant rights? if given rights they will be able to delete also, right?
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Only if you grant right to delete.

/gustav
WSStudent

Author

Commented:
with modify , delete grand are automatically checked in permissions in Server.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
But if Delete is not granted on the folder itself, users cannot delete.

/gustav
WSStudent

Author

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
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Right-click folder, Properties, Security.
Unmark Editing (and Full Control).

/gustav
WSStudent

Author

Commented:
done, and now also i can delete files,any idea?
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
You may have to click Show Advance Options  (at right).
Then you'll see the Delete option:

Permissions.PNG
/gustav
WSStudent

Author

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
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
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
WSStudent

Author

Commented:
not working, any other idea?
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Sorry, no.

/gustav
WSStudent

Author

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.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

/gustav

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial