need help to get file list onto form - using filepath from field on active form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • katia
    New Member
    • Feb 2011
    • 13

    need help to get file list onto form - using filepath from field on active form

    i am lost. i cannot figure out how to make this work, because the dir= is not static but changes every time the form loads, and so, would appreciate help.

    i have an access database 2003 (vb)

    and one of the fields in the database contains the filepath for objects that are stored in various places (could be mp3, doc, pdf, xls - etc)on the drive.

    i have a form that displays a record, including (among other things) the filepath, but not the objects/files found in the filepath folders

    i would like to have the form load, and display a list of the objects/files found in the folder for the file path displayed on the active record - in a separate field but on the same form

    i would like it to refresh if new objects/files have been added since the last view

    i would like to be able to generate a report that shows the objects/files in the file path on the active form and that will update when new objects/files are added

    if you need more information please get back to me.
    Last edited by katia; Feb 18 '11, 08:13 PM. Reason: clarity
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Add a Filelistbox to the form and set the File1.path = path from the record in the DB.
    To refresh the contents of the list: enter the code= File1.refresh
    To dump the contents of the list:
    Code:
    Dim i As Integer
    Dim TEXTCONT As String
    For i = 0 To File1.ListCount - 1
       TEXTCONT = TEXTCONT & File1.List(i)
    Next
    You can now send it to the printer or a file.

    Comment

    • katia
      New Member
      • Feb 2011
      • 13

      #3
      Hello Guido;
      Thank you. I have tried this but it does not work. I have the File1 = using DLookup - is this the wrong approach? It gives me errors and does not like it as file path.........

      Dim File1 As String
      File1 = DLookup("[File_Path_On_Ne twork]", "[Records Investments Group]")

      Dim i As Integer
      Dim TEXTCONT As String
      For i = 0 To File1.ListCount - 1
      TEXTCONT -TEXTCONT & File1.List(i)
      Next

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        File1 is the name of the filelistbox.
        You have to set the path from the database to the component FilelistBox.
        Like:
        Code:
        Dim FILEPATH As String
        FILEPATH = ??? 'ยง Path from the database
        File1.Path = FILEPATH
        You have to replace the ??? with the data from the record in the database !

        Comment

        • katia
          New Member
          • Feb 2011
          • 13

          #5
          ' problem with DLookup and lstFilesInDirec tory.Path is
          ' errors - why? *sharp stick in eye*


          Dim FILEPATH As String
          FILEPATH = DLookup("[File Path on Network]", " Records Investments Group") = Form![Records Investments Group ALL Fields]
          lstFilesInDirec tory.Path = FILEPATH

          Dim i As Integer
          Dim TEXTCONT As String
          For i = 0 To lstFilesInDirec tory.ListCount - 1
          TEXTCONT = TEXTCONT & lstListofRecord s.List(i)
          Next

          Comment

          • katia
            New Member
            • Feb 2011
            • 13

            #6
            FYI: is populating but with a list of sequential numbers, if you click on the list box - gets compile error: method or data member not found. (lstFilesInDire ctory.Path

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              sorry for the misunderstandin g (I was trying to list from VB6 via an access DB).
              The problem is in VBA access or not ?
              If so, please place the call in the forum "Microsoft Access / VBA".
              Access is not my dada but I have found next:
              where
              TextFolderPath. Text: textbox wih link to datafield with path of folders.

              Code:
              Dim sFile As String
              Dim FilePath As String
                 FilePath = TextFolderPath.Text
                 If FilePath <> "" Then
                    sFile = Dir$(FilePath & "\*.*", vbNormal Or vbHidden Or vbSystem Or vbReadOnly Or vbArchive)
                    TextList.SetFocus
                    TextList.Text = ""
                    Do Until sFile = ""
                       TextList.Text = TextList.Text & FilePath & "\*.*" & sFile & vbNewLine
                       sFile = Dir$()
                    Loop
                    Form_TblFolders.SetFocus
                 Else
                    MsgBox "record is empty"
                 End If

              Comment

              • katia
                New Member
                • Feb 2011
                • 13

                #8
                It is Access VBA! -and- Thank you for your help.

                Comment

                Working...