Results 1 to 4 of 4

Thread: [RESOLVED]Access, Check Dir Existence, Make Dir, CopyFile

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    19

    [RESOLVED]Access, Check Dir Existence, Make Dir, CopyFile

    Hello Im doing my project well with ur great help. I have a problem with checking if dir/file on Server exist. I use ODBC and my connectivy is working. I use code to check if DIR exist.

    Code:
    If Dir("\\Servername\Dirname\") <> "" Then
    
            MsgBox "It Exists!"
    
        Else
    
            MsgBox "No Go!"
    
        End If
    It works for C:\ etc. Im really confused about that. Ofc i can see Dir's on server from explorer. Any ideas?
    Last edited by vitoo; Jun 11th, 2010 at 06:14 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Access, Check Dir Existence, Make Dir, CopyFile

    you must specify to return directories as well as files
    vb Code:
    1. If Dir("\\Servername\Dirname\", vbDirectory) <> "" Then
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Access, Check Dir Existence, Make Dir, CopyFile

    And if you don't know what it is you could try...
    vb Code:
    1. Private Sub CommandButton1_Click()
    2.     Dim sDir As String
    3.     sDir = "\\Servername\Dirname\"
    4.     If Len(Dir(sDir, vbDirectory)) Then
    5.         If (GetAttr(sDir) And vbDirectory) = vbDirectory Then
    6.           MsgBox sDir & " does exist and is a FOLDER"
    7.         Else
    8.           MsgBox sDir & " does exist and is a FILE"
    9.         End If
    10.     Else
    11.         MsgBox sDir & " does not exist as anything."
    12.     End If
    13. End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    19

    Re: Access, Check Dir Existence, Make Dir, CopyFile

    Guys great work! I wonder if it can check only a dir
    Edit
    It Can

    Guys like alwyas GREAT WORK!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width