Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2014
    Provided Answers: 1

    Unanswered: Search and How to display the files in a directory

    We want to create a Form for searching. We want the results to return the names of files (linked if possible), from a specific folder location on a "Shared" drive.

    For example: We have Product X. We want to search for and need to "see" documentation for Product X concerning Admin Procedures, or Reference Materials, or User Manual.

    Is this doable?

    Please advise. Thanks.

  2. #2
    Join Date
    Apr 2014
    Provided Answers: 32
    i have a listbox of the files connected to table: tFiles ...
    and a textbox: txtFolder has the folder name

    Public Sub ReloadFilesIntoList()
    PutFilesInDir2List txtFolder, ".xls"
    End Sub
    Public Sub getFilesInDir2List(ByVal pvDir, Optional ByVal pvPattern)
    Dim fso, oFolder, oFile, oRX
    Dim colFiles 'As Collection
    Dim sTxt As String, sFile As String
    DoCmd.SetWarnings False
    If IsMissing(pvPattern) Then pvPattern = ""
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oFolder = fso.GetFolder(pvDir)
       'empty the file table
    sSql = "Delete * from tFiles"
    DoCmd.RunSQL sSql
        'load file table with the files
    For Each oFile In colFiles
          if instr(,pvpattern)>0 then
               sSql = "INSERT INTO tFiles ( FileName ) Values ('" & oFile.Name & "')"
              DoCmd.RunSQL sSql
         end if
    Set fso = Nothing
    Set fso = Nothing
    Set fso = Nothing
    Set oFolder = Nothing
    DoCmd.SetWarnings True
    End Sub
    Last edited by ranman256; 06-17-15 at 10:54.

Posting Permissions

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