Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Directory and Files (MSACCESS 2003)

    Dare I cime back? I am trying to do a varient form to show in a list:

    DIRA/Document 1
    DIRA/Document 2
    etc
    DIRA/DIRA2/Document 1
    DIRA/DIRA2/Document 2
    etc
    DIRA/DIRA2/DIRA3/Document 1
    DIRA/DIRA2/DIRA3/Document 2

    Then it continues with the next sequence of

    DIRB/Document 1
    ETC, ETC

    I have been trying to use the code below but get further away from anything that will work

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fld = fso.GetFolder(MainDir)

    ' Loop through the folders
    For Each sfl In fld.SubFolders

    ' Loop through the files in the subfolder
    For Each fil In sfl.Files
    Me.List126.AddItem sfl.Name & " | " & fil.Name
    Next fil


    Next sfl


    Many thanks. Last time I will come back on this

  2. #2
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Directory and Files (MSACCESS 2003)

    Progressed further, however I cannot find how to add the full directory path of each document in the list. (in front of document name
    Any help greatly appreciated.

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fld = fso.GetFolder("K:ESPNCSCProductionITWS TRANSCRIPTIONS")

    For Each sfl In fld.SubFolders
    Me.List126.AddItem sfl.Name ' Main Directories

    ' NEED TO GET DOCUMENTS IF ANY IN HERE

    ' Loop through the files in the folder
    For Each fil In sfl.Files
    Me.List126.AddItem sfl.Name & " | " & fil.Name
    Next fil

    ' Now I have the directory name, list the 1st subdirectory names
    Set fld2 = fso.GetFolder("K:ESPNCSCProductionITWS TRANSCRIPTIONS" & sfl.Name)

    For Each sfl2 In fld2.SubFolders
    Me.List126.AddItem sfl.Name & " | " & sfl2.Name

    ' NEED TO GET DOCUMENTS IF ANY IN HERE

    ' Loop through the files in the folder
    For Each fil In sfl2.Files
    Me.List126.AddItem sfl2.Name & " | " & fil.Name
    Next fil

    ' Now I have the Maindirectory & 1st Subdirectory, list the second subdirectory
    Set fld3 = fso.GetFolder("K:ESPNCSCProductionITWS TRANSCRIPTIONS" & sfl.Name & "" & sfl2.Name)

    For Each sfl3 In fld3.SubFolders
    Me.List126.AddItem sfl.Name & " | " & sfl2.Name & " | " & sfl3.Name

    ' NEED TO GET DOCUMENTS IF ANY IN HERE

    ' Loop through the files in the folder
    For Each fil In sfl3.Files
    Me.List126.AddItem sfl3.Name & " | " & fil.Name
    Next fil

    Next sfl3

    Next sfl2

    Next sfl

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Directory and Files (MSACCESS 2003)

    Why in heaven's name are you trying to emulate Windows in your database? Windows Explorer does all of what you want, and more. And if you want to let the user select a file or folder, you can use Application.FileDialog.

  4. #4
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Directory and Files (MSACCESS 2003)

    Thanks Hans. I have managed to complete it. I need all this in a database application as it links records to documents and a whole lot more. The user wants to do all this within an Access program. But thanks anyway, I got there using all the bits you had given me during this phase. Best regards

Posting Permissions

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