none
MkDir won't work when I change path from driver letter to IP address RRS feed

  • Question

  • Hi

    I have some VBA code in which part of it creates a new directory in which to store files.  When the destination address (which is a server) is specified using a driver letter everything is fine, but if I identify the same destination by starting with the IP address of the server then I get error 76 Path not found.

    Could somebody help me with one please.


    Chris | UK

    Monday, July 4, 2016 2:19 PM

Answers

  • Hi ChrisParkin,

    did you check the value when you got error?

    if not please try to debug your code and see which value is there after you combine the Destroot + WorksNo .

    match that value with path you are passing manually.

    if you find any difference between them then again check your code step by step and try to make it correct.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    Tuesday, July 5, 2016 9:25 AM
    Moderator
  • As you're stepping through, observe the Locals window for value changes. You can also hover over a variable and get a tooltip with the value, or you can use the Immediate window:
    ?myVariable
    or
    ?myExpression


    -Tom. Microsoft Access MVP

    • Marked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    Tuesday, July 5, 2016 1:16 PM

All replies

  • According to my tests it seems like Dir (like MKDir) does not accept ip addresses, neither in the form of a plain address  (192.168.1.1) nor prefixed with double backslashes (\\192.168.1.1) followed by a share name.

    You need to make a plan to always use the server name.


    Best regards, George

    Monday, July 4, 2016 4:35 PM
  • That's not my experience. I can run this:

    mkdir "\\192.168.1.195\testshare\test1"
    and it correctly creates a test1 folder in that share.

    Doing that from a mapped drive works as well.

    Not sure what's going on with you. My money is on some permissions issue. When you create the mapped drive you can specify alternate credentials; maybe you did that and that's why it works through the mapped drive.


    -Tom. Microsoft Access MVP

    Monday, July 4, 2016 4:51 PM
  • It has to be a permissions issue. Make sure you have permissions (rights) to write to that directory.

    Also, you should have a UNC path of:
    \\ServerName\foldername\foldername\etc\foldername\


    MY BOOK

    Monday, July 4, 2016 6:44 PM
  • Hi ChrisParkin,

    please make sure that your mentioned path in the code is correct. because you got the path not found error.

    For the error description please visit the link below.

    Path not found (Error 76)

    I think that the problem is in the path.

    otherwise you will get following error.

    Path/File access error (Error 75)

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 5, 2016 12:40 AM
    Moderator
  • Hi and thanks for the replies.

    The path is not named within the code but taken from an input form prior to clicking 'DoUpload' button.

    Private Sub DoUpload(sourcePath As String)
        ' Decompose the sourcePath
        Dim Ext As String
        Dim DestRoot As String, DestFolder As String, DestFileName As String
    
        SourceFilename = Tools.ExtractFileName(sourcePath)
        Ext = Tools.ExtractFileExtension(sourcePath)
        
        DestRoot = Tools.GetSettingDestRoot()
        DestFolder = Tools.PathCombine(DestRoot, WorksNo)
        ' Create DestFolder
        If Not DirExists(DestFolder) Then MkDir DestFolder
        
        DestFileName = DocID & "." & Ext
        DestPath = Tools.PathCombine(DestFolder, DestFileName)
        
        ' Copy File
        
        FileCopy sourcePath, DestPath
        
        ' OK Msg
        Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    Msg = "Uploaded.  Click OK and Close"
    Style = vbOKOnly + vbInformation + vbDefaultButton1
    Title = "All Done"
    Ctxt = 1000
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    If Response = vbOK Then
        MyString = "OK"
    Else
    End If
    End Sub

    So 'DestRoot' is entered by the user and 'DestFolder' is Destroot + WorksNo combined.  As the code works fine when identifying the server path as V:\This Folder\That Folder, I don't get why it becomes a problem when it is identified by its IP address (\\192.168.1.57\This Folder\That Folder).

    I can access the server from my machine by both drive letter and IP address and I can manually create directories in the path I am asking the code to create the directory.

    I will speak with our server technician as I guess it may be possible that the permissions may be saying the MS Access is not allowed to create directories.  Hmm, but then it can when using a drive letter!! I'm afraid this one has me beat so any further ideas would be much appreciated.

    Thanks.


    Chris | UK

    Tuesday, July 5, 2016 8:59 AM
  • Hi ChrisParkin,

    did you check the value when you got error?

    if not please try to debug your code and see which value is there after you combine the Destroot + WorksNo .

    match that value with path you are passing manually.

    if you find any difference between them then again check your code step by step and try to make it correct.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    Tuesday, July 5, 2016 9:25 AM
    Moderator
  • Thanks Deepak

    Stupid question but how do I get VBA to tell me what it is valuing Destroot + WorksNo at?


    Chris | UK

    • Marked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    • Unmarked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    Tuesday, July 5, 2016 9:40 AM
  • As you're stepping through, observe the Locals window for value changes. You can also hover over a variable and get a tooltip with the value, or you can use the Immediate window:
    ?myVariable
    or
    ?myExpression


    -Tom. Microsoft Access MVP

    • Marked as answer by ChrisParkin Tuesday, July 5, 2016 2:39 PM
    Tuesday, July 5, 2016 1:16 PM
  • Deepak and Tom

    Thank you very much.  Your suggestion found the problem and proved to myself that I'm an idiot!!


    Chris | UK

    Tuesday, July 5, 2016 2:39 PM