Link to home
Start Free TrialLog in
Avatar of WS
WSFlag for United Arab Emirates

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try to get admin rights if possible. As i guess, getting the admin rights will help your cause
That won't help. Users should at no time run with admin rights.

/gustav
Avatar of WS

ASKER

@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.
Please review my first comment.

/gustav
Avatar of WS

ASKER

@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?
You also need to grant rights for the share.

/gustav
Avatar of WS

ASKER

how to grant rights? if given rights they will be able to delete also, right?
Only if you grant right to delete.

/gustav
Avatar of WS

ASKER

with modify , delete grand are automatically checked in permissions in Server.
But if Delete is not granted on the folder itself, users cannot delete.

/gustav
Avatar of WS

ASKER

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
Right-click folder, Properties, Security.
Unmark Editing (and Full Control).

/gustav
Avatar of WS

ASKER

done, and now also i can delete files,any idea?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WS

ASKER

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
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
Avatar of WS

ASKER

not working, any other idea?
Sorry, no.

/gustav
Avatar of WS

ASKER

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.
You are welcome!

/gustav