Results 1 to 6 of 6
  1. #1
    lousg
    Guest

    Combo box of file names

    Is there a way to create 3 combo boxes showing: 1-Explorer directories, 2-Folders in the selected directory and 3-files in the selected folder. We take alot of photos and store them in different directories based on their subject. I would like for the users to be able to use drop downs to quickly view the photo/s that they are interested in. Thanks for any help.

  2. #2
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Combo box of file names

    I can offer some help for at least one point of your question. I had to do a form with a listbox to show all *.mdb files in a given directory. As using a field as rowsource for a listbox needs somewhat complex code (in A97) I choose to create a table holding the filenames which are retrieved using the Dir$() statement. The code to fill the listbox looks like this:

    Private Sub Form_Open(Cancel As Integer)
    Dim dbMe As DAO.Database
    Dim rsFile As DAO.Recordset
    Dim strPath As String
    Dim strTest As String

    Set dbMe = CurrentDb()

    '----- Create table to take the filenames as rowsource for the listbox
    CurrentDb.Execute "DROP TABLE zttblFL" ' just in case it was still there
    CurrentDb.Execute _
    "CREATE TABLE zttblFL ([FName] text CONSTRAINT FName PRIMARY KEY);"
    dbMe.TableDefs.Refresh

    strTest = Dir$(<YourPathHere> & "*.mdb") ' this would only find *.mdb files
    Set rsFile = dbMe.OpenRecordset("zttblFL")
    Do Until strTest = ""
    strTest = Mid$(strTest, RInstr(strTest, "") + 1) ' using a custom RInstr()
    ' function to get rid of the path and keep only the filename
    rsFile.AddNew
    rsFile!FName = strTest
    rsFile.Update
    strTest = Dir$ ' retrieving the next file
    Loop
    rsFile.Close
    [lstFiles].RowSource = "SELECT FName FROM zttblFL ORDER BY FName"

    End Sub

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Combo box of file names

    There is a The Access Web that might give you some ideas.
    Charlotte

  4. #4
    lousg
    Guest

    Re: Combo box of file names

    Thanks. That worked. I was able to create a combo box that listed all of the directories. I was also able to make one that listed all of the .jpg files in the chosen directory. But, when I change directories in my first combo box, then try to make a change in the second one,I get an error. Any suggestions?

    Please keep in mind...I am not a programmer! I can usually hack my way through this stuff, but that can take hours. Thanks again for any help.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Tennessee
    Posts
    194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo box of file names

    did you requery the second combo box when you clicked in the first combo box

  6. #6
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Combo box of file names

    If you change the directory in one box you must make the other box with the filenames "know" about it. Use the "AfterUpdate"-event of the directory-box to write a procedure which does the following:

    1. Delete the records in your filetable
    (Use: CurrentDb.Execute "DELETE * FROM <YourTable>")
    2. Get the files of the newly chosen directory
    with the method used in Form_Open()
    3. Instead of repeating the <YourControl>.Rowsource=<xxx>
    command use: <YourControl>.Requery to show the new data

Posting Permissions

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