Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Posts
    87

    Unanswered: Categories with ComboBox?

    Hello, i have a question.

    I have made a table1, that has product list and categories for each product.Then i have made table2, and set look-up option (Combo-box) with the source to table1.After that i created form2, to be able to fill up records by using this combo-box (and products from table1). But there are too many products, and it is hard to navigate through them. I am thinking of creating categories for these products (actually they are already made in table1) and make availablity to select category first, and then - product.

    Is it possible to make it, and how? Maybe two combo-box'es, first you select category in first field, then second box fills up with the records for that category only and then you select particular product.....only how to do it, any ideas? Or maybe someone already made such thing.


    Thank you
    YZF

  2. #2
    Join Date
    May 2004
    Posts
    65

    Creating a second combo box

    Create both combo boxes on the form.

    Leave the rowsource field blank on the second box

    On the first combo box write code for the 'after update' condition

    On the after update condition write a code like
    combo2.rowsource = "select * from partlist where category = [forms]![myformname]![combo1]));

  3. #3
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by gavinfm
    Create both combo boxes on the form.

    Leave the rowsource field blank on the second box

    On the first combo box write code for the 'after update' condition

    On the after update condition write a code like
    combo2.rowsource = "select * from partlist where category = [forms]![myformname]![combo1]));

    I tried, but i get errors....probably syntax is bad... I changed "myformname" and "combo1" "combo2'...anything else i should change?

    Thanks

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Google this one. It is a very common question and you will get great examples.

    The keywords you want to search for are "cascading combo boxes".

    As far as the example given, you did change the relevant parts of the SQL query right?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    May 2004
    Posts
    65

    Try this

    I only wrote the concept not the actual code:

    This is the actual code:
    '******** Start of Code
    [combo2].RowSource = "SELECT DISTINCTROW field1, field2, field3 FROM subheadings WHERE (((field1)=[combo1]));"
    [combo2].Requery
    '******* End of Code
    Where:
    combo1 is the first list box on the form
    combo2 is the second list box that you wish to update
    field1 -3 are the fields that you wish to display (you may need more or less)
    field1 is the categorycode that combo1 will provide

    ie If combo 1 is category then

    your new row source will detail the fields where field1 is equal to the selected category.

    Hope that helps

  6. #6
    Join Date
    Oct 2005
    Posts
    87
    Quote Originally Posted by gavinfm
    I only wrote the concept not the actual code:

    This is the actual code:
    '******** Start of Code
    [combo2].RowSource = "SELECT DISTINCTROW field1, field2, field3 FROM subheadings WHERE (((field1)=[combo1]));"
    [combo2].Requery
    '******* End of Code
    Where:
    combo1 is the first list box on the form
    combo2 is the second list box that you wish to update
    field1 -3 are the fields that you wish to display (you may need more or less)
    field1 is the categorycode that combo1 will provide

    ie If combo 1 is category then

    your new row source will detail the fields where field1 is equal to the selected category.

    Hope that helps

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •