Combo Boxes - Cascading Folders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ehsan arman
    New Member
    • Jan 2011
    • 49

    Combo Boxes - Cascading Folders

    Hi I have two Combo boxes on a form:
    1- Neighbourhood
    2- Invoice

    in the neighbourhood combo box I read in folder names on a particular drive(so whatever is the folder names are say on X:\Construction appear in the combo box).

    what I want to be able to do is by selecting one of the neighbourhoods in the first combo box have the 2nd one show only whats inside the selected neighbourhood(s o to essentially show the subfolder names within the selected neighbourhood folder. For example if I select Laurier Heights as the neighbourhood I want the Invoice Combo box to show whats inside that folder.
    I have used the following code for filling up a combo box with folder names:

    Code:
    Dim fs, f, f1, fc, s
    Dim folderspec
    folderspec = "X:\Construction\Engineering\Upgrading Group\Mature Neighbourhood Rehab Drainage\2. CCTV\2.07 Invoices\"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    For Each f1 In fc
    Me!Combo29.AddItem f1.Name
    Next f1
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Try looking at Cascaded Form Filtering.

    Comment

    • Ehsan arman
      New Member
      • Jan 2011
      • 49

      #3
      Hi I read that article but I'm not sure if I could understand how to relate that with filtering folder/file names on a Drive and using them in a combo box. Can you tell me how thats done?
      Thanks.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Did you play around with the example database? I'm really not sure what more I can say. You give no indication of where you're confused and the info's all there it seems to me. If you can specify a particular difficulty maybe I could help.

        Comment

        • Ehsan arman
          New Member
          • Jan 2011
          • 49

          #5
          Maybe I didn't phrase my question properly. I need to show the contents of a folder inside a combo box based on the selection made in another combo box. So let's say I choose a neighbourhood from a combo box captioned neighbourhood. Let's take the neighbourhood name as Laurier Heights for example, I want to be able to see the contents of the Laurier Heights folder in another combo box next to the neighbourhood one. It was not clear on how your example database represented this.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            So, it seems the cascading you're referring to is not related to a database at all, but rather to the file system (sub-folders within folders). Is that right?

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              Well, you already have code to list out folders in a combo box. And the cascading form filtering articles shows you how to retrieve a selected value and then apply it to another control. All you have to do is take your code and apply the concepts from the article.

              Comment

              • Ehsan arman
                New Member
                • Jan 2011
                • 49

                #8
                yes Neopa thats right, I am not using any tables or queries for the combo boxes, just folders/subfolders kind of like windows explorer where you select a folder and it narrows down to a bunch of subfolders. I want to facilitate that in my database form.

                Comment

                • Ehsan arman
                  New Member
                  • Jan 2011
                  • 49

                  #9
                  Rabbit, I am trying to do something like windows explorer in the database which opens up subfolders within folders and then finally selecting a file based on a criteria(like matching a certain date on the file name).

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    Yes, I know what you're doing. I'm just saying that you have everything you need. You already have the code to list folders and add them to a combo box. You just need to apply the concepts from the article to your code.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32633

                      #11
                      We can take it in smaller steps if you need to Ehsan.

                      Let's start by your telling me what, if anything, you code does and what it doesn't do. The wrapper info would help here too - as in what is the header for the procedure it's in.

                      Comment

                      • Ehsan arman
                        New Member
                        • Jan 2011
                        • 49

                        #12
                        Hi, my code is supposed to open up an excel file for transfer into my Access database. The excel files are contained in a folder named Invoice.Dependi ng on the date of the files they are contained in different invoice folders(#1,#2,# 3 and so on.) The invoice folder is a subfolder to another folder named Neighbourhood and there are many of these Neighbourhood folders, so on my database form I made combo boxes for both Neighbourhood and Invoice. By selecting the appropriate neighbourhood I want to show the contents of that folder( which is an invoice) on the Invoice combo box and then by clicking on the Invoice folder I can select the excel file I want to import into the database.

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32633

                          #13
                          Originally posted by NeoPa
                          NeoPa:
                          Let's start by your telling me what, if anything, you code does and what it doesn't do.
                          You seem to have told me what you want it to do instead of both of the things that I suggested you tell me. You're going to find technical work difficult unless you show more focus on the matter in hand.

                          Comment

                          • Ehsan arman
                            New Member
                            • Jan 2011
                            • 49

                            #14
                            ok well, what my code does do is show the names of the Neighbourhood folders contained on my X drive. what it does not do is that it doesn't show the contents of the neighbourhood folder(which are the invoices) inside the Invoice combo box. I can show snippets of my code if that helps in any way.

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32633

                              #15
                              I see very little evidence that you have even read my post #11.

                              Yes. If there is any code not already posted that is relevant, then it would probably help to see it. The code that has been posted already could suffer being posted again within the context of the headers of whatever procedure it's contained in. The header/declaration line holds much useful information, particularly when it's pretty well all the information here (I know the name of the second ComboBox from your code - not your post - but I would be able to infer the name of the first with the header, assuming it's an event procedure associated with it).

                              From the code already posted, it's clear why only the folders are shown in combo29 on your form. Line #6 says Set fc = f.SubFolders. It would not be likely to include files in that property collection.

                              From your explanation in post #1 you only have two ComboBoxes. You say there you want the subfolders to show in the Invoice ComboBox, then you go on to give an example that indicates you want invoices files shown there instead. How can I help with a question when you don't seem to know what the question is to start with? I do intend to help of course, but I think you need to start being clearer with what you want and a bit freer with passing sensible information across, because I'm finding helping you very difficult to this point.

                              Comment

                              Working...