473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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(so 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:

Expand|Select|Wrap|Line Numbers
  1. Dim fs, f, f1, fc, s
  2. Dim folderspec
  3. folderspec = "X:\Construction\Engineering\Upgrading Group\Mature Neighbourhood Rehab Drainage\2. CCTV\2.07 Invoices\"
  4. Set fs = CreateObject("Scripting.FileSystemObject")
  5. Set f = fs.GetFolder(folderspec)
  6. Set fc = f.SubFolders
  7. For Each f1 In fc
  8. Me!Combo29.AddItem f1.Name
  9. Next f1
  10.  
Mar 25 '11 #1
17 2822
NeoPa
32,556 Expert Mod 16PB
Try looking at Cascaded Form Filtering.
Mar 25 '11 #2
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.
Mar 28 '11 #3
NeoPa
32,556 Expert Mod 16PB
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.
Mar 29 '11 #4
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.
Mar 29 '11 #5
NeoPa
32,556 Expert Mod 16PB
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?
Mar 31 '11 #6
Rabbit
12,516 Expert Mod 8TB
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.
Apr 1 '11 #7
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.
Apr 1 '11 #8
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).
Apr 1 '11 #9
Rabbit
12,516 Expert Mod 8TB
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.
Apr 1 '11 #10
NeoPa
32,556 Expert Mod 16PB
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.
Apr 2 '11 #11
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.Depending 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.
Apr 4 '11 #12
NeoPa
32,556 Expert Mod 16PB
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.
Apr 4 '11 #13
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.
Apr 4 '11 #14
NeoPa
32,556 Expert Mod 16PB
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.
Apr 4 '11 #15
sorry, that's the best I could do in terms of explaining the issue at hand. I don't know what else I could add to make things clearer, but it's ok I am thinking of using a different approach to avoid using a 2nd Combobox. This will fix the problem.
Thank you.
Apr 5 '11 #16
Rabbit
12,516 Expert Mod 8TB
I don't understand all the confusion. If you read the articles, then you know that you need to use the after update event of the combo box to fill the second combo box.

Knowing that, you just need code to fill that combo box based on the selection in the first combo box. You already have that code. The only change you need to make is to make the path dynamic rather than static.

So then really all you need to do is
folderspec = Me!Combo29

It's practically a copy and paste job.
Apr 5 '11 #17
NeoPa
32,556 Expert Mod 16PB
I too, find it hard to understand your difficulty. You just have to read what I've said (I've laid it all out pretty fully I thought), then respond to each point or question. Never mind. Sometimes understanding other people is more complicated than one would guess. At this point I see no profit from delving further into this aspect.

As a parting suggestion, I would consider a setup where you still have two ComboBoxes, but also a TextBox - Let's call them cboFolder, cboFile and txtFullFolder - and every time a folder is selected from cboFolder do all three of :
  1. Update txtFullFolder to reflect the full folder name of the currently selected folder.
  2. Update cboFolder to show the subfolders of the current folder
  3. Update cboFile to show the matching files of the current folder.

I believe this approach would serve your requirement well. The .SubFolders collection will give you the available folders. I would guess there would be a similar collections for files, probably called .Files. I would expect that to be all you need to arrive at a smoothly working solution, but I'll leave that with you now as communication between us seems overly difficult.
Apr 5 '11 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding ...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
2
by: ShadowHawk | last post by:
Hi Everyone. I've been having a little touble with a form I'm working on. (I'm a MS Access hobbiest). I've set up the cascading combo boxes, which is working, (I took the code from Microsoft) on a...
2
by: SPOILED36 | last post by:
I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and...
3
by: buddyr | last post by:
Hello, Yesterday I recieved help with two cascading combo boxes on an access form. I went the link http://www.fontstuff.com/access/acctut10.htm And basically used their first example. Now I...
4
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...
7
by: Toireasa | last post by:
Hi, Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience! I'm using Access 2007, in XP. I'm...
3
by: buddyr | last post by:
Hello, I was able to use the example on Cascading /List boxes on the site here for 2 combo boxes. http://bytes.com/topic/access/insights/605958-cascading-combo-list-boxes Is there a way to add...
3
by: dblack64 | last post by:
I am working in Access 2007. I have a form named Master Terms List that contains 4 bound text boxes and 7 cascading combo boxes. The bound text boxes have data sources from a table named Termslist. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.