Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    I can't get the DIR function to return anything other than a zero length string


    I can't get the DIR function to return anything other than a zero length string...................I must be loosing it! (I hard coded the directory expression for purposes of the post. The directory expression normally is passed in an unbound text box.)

    Code:
    Option Compare Database
    Dim strFileName As String
    
    Private Sub FixCommand_Click()
    strFileName = Dir("c:\crs")
        While strFileName <> ""
        Debug.Print
        Wend
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Hey Bill! If that's a folder, try adding "\" at the end, as I think it's necessary.

    By the way, that loop will never end, I suspect. Or never start.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    crs is a folder?

    Try:

    Dir("C:\crs\")

    EDIT: Agree, looks like an endless loop, review http://www.allenbrowne.com/ser-59.html

    Or use If Then structure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Results of a brief test:

    Code:
    ?dir("c:\accessap")
    
    ?dir("c:\accessap\")
    CabWebReservations.accdb
    so it appears the \ is required as I suspected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, one needs the "\". The revised code works okay for the files within the folder "CRS", but fails to drill down into the sub-directories. I need to be able to examine the entire "CRS" tree, including its sub-directories.

    Code:
    Option Compare Database
    Dim strFileName As String
    
    Private Sub FixCommand_Click()
    strFileName = Dir("c:\crs\")
        While strFileName <> ""
        Debug.Print strFileName
        strFileName = Dir
        Wend
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    See post 3.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Got it, thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2013, 04:35 PM
  2. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  3. Replies: 3
    Last Post: 11-22-2012, 08:01 PM
  4. Function to return a set of records?
    By vicrauch in forum Access
    Replies: 2
    Last Post: 07-12-2011, 08:27 AM
  5. Replies: 1
    Last Post: 06-23-2010, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums