Hello Everyone!
I have a question regarding "cascading combobox(s) list(s)"
I would like:
ComboBox 2 to show results from ComboBox 1's selection,
then ComboBox 4 to show results from ComboBox 3's choice
For Instance these are the combo boxes
[category] [subcategory] [type] [subtype]
This is the sample of choices in the combo boxes
HARDWARE - CABLES - USB - 2.0
HARDWARE - CPU - AMD - AM2
QUESTION(s)
Do I create ONE table for this? OR
Do I create 4 tables = tblcategory tblsubcategory tbltype tblsubtype ?
Do I place a QUERY in the middle of the TABLE(s) and the FORM?
Should I use VBA to make this work?
Should I use sql in the control source to make this work?
What is the best solution? so many answers, so many posts,..
a lookup in a table field.
thank you in advanced!!!
Matt
34 12605 FishVal 2,653
Recognized Expert Specialist
Hi, Matt.
So basically you want a tree with "one parent has many childs". You need one tables for this. - tblCategories
-
keyCategoryID Autonumber(Long) PK
-
txtCategoryName Text
-
keyParentCategory FK(tblCategories.keyCategoryID)
-
And take a look at Cascading Combo/List Boxes
Hello,
thank you for your reply FishVal, I appreciate it.
that article you gave me is excellent.. I found it yesterday.
HOWEVER it deals with 2 comboboxes
Company and Employees
I have 4
category subcategory type subtype
and I really don't know how to make this VBA code go past 2 columns, it only deals with 2.. Company and Employees
would I add another ELSE section? or just make another module for type!?! i think I am getting it! - Private Sub Company_AfterUpdate()
-
With Me![category]
-
If IsNull(Me!Company) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT [EmpName] " & _
-
"FROM TblEmployees " & _
-
"WHERE [ID]=" & Me!Company
-
End If
-
Call .Requery
-
End With
-
End Sub
FishVal 2,653
Recognized Expert Specialist
Hi, there. I really don't understand your difficulties.
Place the folllowing code in AfterUpdate event handlers of each combo but the last one. Assumed you are going with table structure I suggested in post#2 and combos are 2-column (keyCategoryID, txtCategoryName ), the first is bound and invisible (column width is set to 0). -
Private Sub <level N combo>_AfterUpdate()
-
With Me![<level N+1 combo>]
-
If IsNull(Me![<level N combo>]) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT keyCategoryID, txtCategoryName " & _
-
"FROM tblCategories " & _
-
"WHERE keyParentCategory=" & Me![<level N combo>] & ";"
-
End If
-
Call .Requery
-
End With
-
End Sub
-
Other options: - you have 1 combo which changes it's own RowSource in AfterUpdate to walk down the tree; this case you should think how you want to walk up level one or/and to the topmost categories level
- you use treeview control to browse through categories
Hello FishVal,
thank you for your time.
the table structure you suggested in post#2 is for ONE TABLE.
and that is a table called tblCategories, there is no mention of another table.
the table has 3 columns
1 - keyCategoryID Autonumber(Long ) PK
2 - txtCategoryName Text HARDWARE SOFTWARE
3 - keyParentCatego ry FK(tblCategorie s.keyCategoryID )
2 would hold HARDWARE SOFTWARE
where would CPU, CD, CABLES go?
in the Foreign Key column? I dont think so? really?
FishVal 2,653
Recognized Expert Specialist
Hi, gcoaster. -
keyCategoryID txtCategoryName keyParentCategory
-
1 HARDWARE Null
-
2 SOFTWARE Null
-
3 CPU 1
-
4 CD 1
-
5 CABLES 1
-
6 Office 2007 2
-
7 USB 5
-
8 USB 2.0 7
-
keyCategoryID - inique category key
txtCategoryName - name of category
so far the categories list is flat, to split it to levels add
keyParentCatego ry - =keyCategoryID of the parent category, to make it more representative in table view add lookup feature to the field
Retrieve to the topmost combo records where keyParentCatego ry Is Null.
Still doesn't make you sense?
AH HA!!! now I get it! I took one look at it and now I totally understand..
I am visual.. I had to see an example of it to understand. +
however I dont understand what you mean by flat... when you mention
"so far the categories list is flat,"
AND
" to make it more representative in table view add lookup feature to the field"
FishVal 2,653
Recognized Expert Specialist
AH HA!!! now I get it! I took one look at it and now I totally understand..
I am visual.. I had to see an example of it to understand.
Thats good.
however I dont understand what you mean by flat... when you mention
"so far the categories list is flat,"
I mean that with the first two fields you get table where all categories are equal, no levels defined. The third field - [keyParentCatego ry] adds levels.
AND
" to make it more representative in table view add lookup feature to the field"
Make [keyParentCatego ry] as Number/Long field, then go to "Lookup" tab and set - Display Control = Combo Box
- Row Source Type = Table/Query
- Row Source = SELECT tblCategories.* FROM tblCategories;
- Bound Column = 1
- Column Count = 2
- Column Widths = 0";2"
- the rest as you like
this will transform [keyParentCatego ry] field in table view from textbox to combobox, the drawback is that having added new records you'll need to reopen the table to require the combo.
You may stay without lookup feature and write numbers to [keyParentCatego ry] field, this case no need in table reopening.
Or you may design form where combo rowsource will be required automatically.
NeoPa 32,577
Recognized Expert Moderator MVP
I don't mean to disturb the conversation here, but there is another article ( Example Filtering on a Form.) that may also help. It goes through adding multiple ComboBoxes to filter the data as per the selection.
Please ignore if this would only complicate matters, but you may find it helpful.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Travis Pupkin |
last post by:
Hey,
I've done a number of product catalogs/galleries with one or two
category levels (Category > Subcategory). The straightforward way to do
this, of course, is to use database fields for Category and Subcategory
and query off of those fields.
I have a client now who is interested in what sounds to me to be an
unnecessarily complex catalog with an as of yet undefined number of
category levels at their disposal.
|
by: Rich Protzel |
last post by:
Hello,
So my table contains say 100,000 records, and I need to group the
categories in fld1 by the highest count of subcategories. Say fld1
contains categories A, B, C, D, E.
All of these categories contain subcategories AA, AB, AC, AD,...AJ, BA,
BB...BJ, CA, CB, CC...CJ, etc in fld2.
I am counting how many subcategories are listed for each category. Like
|
by: A.J.M. van Rijthoven |
last post by:
I have a form with data from a box (Table box), on his form is a
subform with the instuments that are in this box. The instruments
(Table instruments) are categorized by category (Table Category). This
is done because there are a verry much different instruments to choose
from. Now I want to choose a category so that the active record in the
subtable (combobox) shows only the instruments that belong to the
selected category. This works...
|
by: Neil Ginsberg |
last post by:
I have a strange situation using Access to automate a Word mail merge. Using
Access 2000 and Word 2000, the code opens Word, opens the document in Word,
sets a table
in the calling Access application as the data source, and then performs a
merge. Everything works fine.
However, when a user uses it in Access 2002 and Word 2002, an extra instance
of the Access application is opened and remains open at the end. Sometimes
it remains open
|
by: Ron |
last post by:
I am trying to create a nested DataList with multiple subcategories listed
under each primary category. Unfortunately, I end up with a bunch of
multiple SubCategory values after iterating through the loop. My code is as
follows:
//****************************************************************
for(int i=0;i<=cat.Count-1;i++)
{
| |
by: bobika |
last post by:
Hi
Im am implementing a small database system using MS Access.
I have two main fields: :product category and product type!
Product category contains ABC and XYZ categories. I added both in the combobox selection just fine.
In category ABC it contains several product types say NB and DT
In cateogfry XYZ it contains different product types say HTand HP.
I made both fields (product type and category) comboboxes.
my problem is that when the...
|
by: Webstorm |
last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost.
Here is the page I am working on:
http://www.knzbusinessbrokers.com/default.asp
I have 3 search critera that I need to use when querying the database. Right now it is only looking for a match on one of those dropdowns and not all 3. can anyone help?
Here is the code:
<form BOTID="0" METHOD="POST" action="businessforsale_interface/Results/test3.asp">
|
by: Brit |
last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The DNS name is "cati", the names are specified in the "Last_names" field, and the categories are in the "categories" field.
l want the results sorted in alphabetic order by last name. However, the results appear to be in a totally random,...
|
by: jillinsky |
last post by:
Wondering is this is possible - I have 2 tables. One is categories,
and has catid, catname, hashighercat, and ...I can't think of the 4th
one, but it isn't needed anyway.
There are 40 categories, and about 1400 subcats. the categories are
numbered 1-40, and the rest have their numbers - all of these are in
the same field - catid. You can tell the categories from the
subcategories by the field hashighercat - the 40 categories are null...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |