Fill Combo List using Criteria selected in another Combo List 
Author Message
 Fill Combo List using Criteria selected in another Combo List

I have 2 (data) Combo Boxes on a VB6. One lists computer component
categories ie Hard Drives, Motherboards, Monitors etc

The other lists the make/model of the components ie Western Digital 10gb
Hard drive.

They are both part of an MS Access(97) Database Table.

What I want to do is have the second one's list limited by the category
selected in the first. ie if the Hard Drive category is selected in the
first, ONLY Hard Drives are listed in the second.

How can this be achieved??

I also want to update a Text Box with the price once the 2 have been
selected, so any help with these would be VERY much appreciated.

Cheers



Fri, 05 Dec 2003 21:27:40 GMT  
 Fill Combo List using Criteria selected in another Combo List
The data sources for each combo should pull from seperate tables obviously.
exp: Catagory Table > Lists the catagories such as Hard Drives,
Motherboards, etc
Each one of these catagories should have some type of primary key value to
uniquely identify
each catagory, a simple autonumber field in the database would work nicely.

In your details table you should have whatever fields you want to describe
the items under each catagory,
but you will also need to have a primary key value here as well AND you must
have another field not necessarily named
the same as in your catagory table, but it must hold the same values as the
primary key values in the catagory table.

Catagory Table:
            (Prim Key)
exp:    CatagoryID    CatagoryName    CatagoryDesc
            1                    Harddrives            Seagate, Western
Digital, etc.
            2                    Motherboards        Magitronic, etc.

Details Table:
            (Prim Key)
           DetailsID    CatagoryID    ItemName                ItemDetails
            1                    1                SeagateHdd
etc, etc
            2                    1                Western Dig hdd
etc, etc
            3                    2                Magitronic MB
etc, etc

linking the tables in this manner, will allow you to later filter anything
out of the details table based on what you select
in the catagory table.  From here place your combo boxes on the form:

combo1
Recordsource is the catagory table
make sure that you set your bound column to CatagoryID (In properties)
combo 1's afterupdate event can be used to run an sql statement filtering
out records from
the details table based on what you selected in combo1 limiting the list
values in combo2.
If you also want to have a text box updated with the price of the item
selected, you could use the
primary key that you created in the details table as the unique identifier
to determine what was
selected in combo2.  I would put the price field in my details table and not
in a seperate table.
Hope this helps a little.  If you have further questions email me at

to continue.


Quote:
> I have 2 (data) Combo Boxes on a VB6. One lists computer component
> categories ie Hard Drives, Motherboards, Monitors etc

> The other lists the make/model of the components ie Western Digital 10gb
> Hard drive.

> They are both part of an MS Access(97) Database Table.

> What I want to do is have the second one's list limited by the category
> selected in the first. ie if the Hard Drive category is selected in the
> first, ONLY Hard Drives are listed in the second.

> How can this be achieved??

> I also want to update a Text Box with the price once the 2 have been
> selected, so any help with these would be VERY much appreciated.

> Cheers



Sun, 07 Dec 2003 15:41:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Fill Combo List using Criteria selected in another Combo List

2. Rebuild select list for combo/list box

3. Updating a combo box list W/limit to list selected

4. Arrays for filling Combo's and Lists ?

5. Speed - Filling many huge combo list boxes

6. Filling a combo list with table names

7. Filling a combo box with a list of files in a direcotry at run time

8. Combo date value set by code gets ignored by combo's list when opened

9. One-Click / Mouse-over on Combo List - subclass combo question

10. Help: One-Click / Mouse-over on Combo List - subclass combo question

11. Listing all tables or queries in a list/combo box

12. How to list macro names in a combo box or a list box

 

 
Powered by phpBB® Forum Software