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

  • Question

  • 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

    Monday, November 27, 2017 7:37 AM

All replies

  • Is the N:\ drive a Trusted Location? Make sure ACCESS considers the drive a Trusted Location.
    Monday, November 27, 2017 2:13 PM
  • Hi Wsm93,

    below are the steps to add trusted location.

    Add a trusted location

    1. Click File > Options.

                   
    2. Click Trust Center > Trust Center Settings > Trusted Locations.

                    
    3. Click Add new location.

               
    4. Click Browse to find the folder, select a folder, and then click OK.

                 

    Remove a trusted location

    1. Click File > Options.

                  
    2. Click Trust Center > Trust Center Settings > Trusted Locations.

                
    3. Select the location to be removed, and then click Remove, and then click OK.

                

    Change a trusted location

                    
    1. Click File > Options.

                
    2. Click Trust Center > Trust Center Settings > Trusted Locations.

                
    3. In the Trusted Locations list, select a location, and then click Modify.

    4. Make the modifications you want, and then click OK.

    Reference:

    Add, remove, or change a trusted location 

    further try to provide full permission on that location and try to test the code again.

    if that work then you need to find for that particular permission and enable it to avoid the issue.

    let us know about your testing results, so that we can try to provide you further suggestions if needed.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Tuesday, November 28, 2017 3:05 AM
  • yes N  drive is a trusted location.
    Wednesday, November 29, 2017 5:23 AM
  • @Deepak, the drive is already added as trusted location.
    Wednesday, November 29, 2017 5:24 AM
  • Hi Wsm93,

    did you try to add the Full Control on that location and try to make the test again? as I mentioned in my last reply.

    if you did that testing then can you inform us about the results?

    if till now you did not check then I suggest you to check it and let us know about it.

    we will try to provide further suggestions to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 29, 2017 6:35 AM
  • I can't give full control to user as there are sensitive documents, but i have given them read and write permission, which i think should work as they are not , also i haven't given them Modify permissions due to requirement that user shouldn't be able to delete any document, if i give them modify permission they will also be able to delete which is not required.
    Wednesday, November 29, 2017 9:09 AM
  • Hi Wsm93,

    I am just telling you to give full control for testing purpose.

    in some other threads , I had read that if you don't provide delete permission then in some cases it will not allow you to create a new file and many other things like this.

    so I just want to confirm this things with you that if you provide full control then it is allow you to copy files or not.

    so my suggestion was only for testing and not to implement it as a solution.

    I will try to find those links and if I got it again then I will try to share it with you.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 29, 2017 9:32 AM
  • when i provide them Modify permission then it start working fine.Also when i give full control it works fine. When i turn modify permission off it starts giving this error.
    Wednesday, November 29, 2017 9:55 AM
  • Hi Wsm93,

    so now you know the root cause of the issue.

    your code is working fine.

    the issue is caused by the permissions.

    further you can try to modify the permissions to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 30, 2017 1:09 AM