Update a data combo based on selection in other data combo 
Author Message
 Update a data combo based on selection in other data combo

Can you update a data combo based on selection in another data combo? If so,
how? I have a Category Table and a Subcategory Table I have put an ADODC
control for each on a form. After the user selects which Category he wants
from a data combo for Category, I want only the other the SubcategoryTitles
for the chosen category to appear in the box.

Category Table Fields:

    CategoryKey (Autonumber) [bound column in cboCategory data combo box]

    CategoryNumber

    CategoryTitle (This is the field I want to show in the cboCategory box,
though if you know a way to show both CategoryNumber and CategoryTitle
together in a data combo, that would really be cool

Subcategory Table Fields:

    SubcategoryKey (Autonumber) [bound column in cboSubcategory data combo

    SubcategoryCode

    SubcategoryTitle



Tue, 23 Sep 2003 01:52:33 GMT  
 Update a data combo based on selection in other data combo
You can do it by setting the recordsource for the second datacombo on the
lostfocus or change event on the first datacombo.

In the lostfocus event do the following:

SQLStmt = "SELECT SubcategoryTitle FROM SubCategory Where CategoryTitle = '"
& cboCategory.Boundtext & "'"
rsSubCat.Open SQLStmt, Connection, adOpenStatic, adLockReadOnly
Set cbosubCategory.RowSource = rsSubCat

To display multiple fields in a datacombo, the fields need to be
concatenated into a single string.  Not really worth it.

Hope this helps.

Suzette


Quote:
> Can you update a data combo based on selection in another data combo? If
so,
> how? I have a Category Table and a Subcategory Table I have put an ADODC
> control for each on a form. After the user selects which Category he wants
> from a data combo for Category, I want only the other the
SubcategoryTitles
> for the chosen category to appear in the box.

> Category Table Fields:

>     CategoryKey (Autonumber) [bound column in cboCategory data combo box]

>     CategoryNumber

>     CategoryTitle (This is the field I want to show in the cboCategory
box,
> though if you know a way to show both CategoryNumber and CategoryTitle
> together in a data combo, that would really be cool

> Subcategory Table Fields:

>     SubcategoryKey (Autonumber) [bound column in cboSubcategory data combo

>     SubcategoryCode

>     SubcategoryTitle



Tue, 23 Sep 2003 12:41:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. enter data in a combo box based on value from another combo box

2. Can you update a data combo based on selection in another data combo?

3. Data bound Combos or Not Data Bound Combos

4. Returning a value from a data combo selection

5. data combo - clear selection

6. Vb Combo list box and Table Data base

7. Data bases and the Combo control

8. Combo Box like Data Bound Combo Box?

9. ***** Question: Finding a record based on the selection from a Combo Box or List

10. ***** Question: Finding a record based on the selection from a Combo Box or List

11. select records based on the selection from the dropdown combo

12. Limit subform combo box by selection in parent combo box

 

 
Powered by phpBB® Forum Software