Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: filter combo box

    Howdy

    Fairly new at this so hope someone can help. Have looked around the forum but can't find a solution to my problem

    I have used the wizard to add a combo box (combo1) that goes to a particular product record that I select in the combo box. This is working fine.

    I also have a combo box (combo2) that runs a macro that filters the records by a product group. This is also working fine.

    What I would like to do is have only the values for the filtered products display in the 1st combo box (combo1) when the filter is run in the second combo (combo2).

    Is there an easy way of only displaying records for the filtered values in the combo box that I am missing?

    Thanks in advance
    ilr

  2. #2
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    You could try the following :
    In the code behind the AfterUpdateEvent of Combo2, you should reset the RowSource for Combo1 and requery it.

    Example : suppose the rowsource for Combo1 is normally this :
    "SELECT ProductNr FROM tblProducts ORDER BY ProductNr;"

    This would give you all the products in your combobox so that you can select one.

    In the code AfterUpdate of Combo2, you can then set this line :
    Me!Combo1.RowSource = "SELECT ProductNr FROM tblProducts WHERE ProductGroup='" & Me!Combo2 & "' ORDER BY ProductNr;"
    Me!Combo1.Requery

    Like this, the Combo1 will only display the products that belong to the ProductGroup you've selected in Combo2.

  3. #3
    Join Date
    Sep 2003
    Posts
    2

    Thumbs up

    Thanks

    That's brilliant, simple and even I could understanding it.

    Regards
    ilr



    Originally posted by Herman
    You could try the following :
    In the code behind the AfterUpdateEvent of Combo2, you should reset the RowSource for Combo1 and requery it.

    Example : suppose the rowsource for Combo1 is normally this :
    "SELECT ProductNr FROM tblProducts ORDER BY ProductNr;"

    This would give you all the products in your combobox so that you can select one.

    In the code AfterUpdate of Combo2, you can then set this line :
    Me!Combo1.RowSource = "SELECT ProductNr FROM tblProducts WHERE ProductGroup='" & Me!Combo2 & "' ORDER BY ProductNr;"
    Me!Combo1.Requery

    Like this, the Combo1 will only display the products that belong to the ProductGroup you've selected in Combo2.

Posting Permissions

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