Combo Box Filter

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi Folks - I know this topic has been discussed before, but I have a little
twist.

I have two combo boxes. The first combo box has four entries. Let's call
them test1, test2, test3, test4.
The second combo box needs to filter its recordsource by the first combo
box. However, the filter is not by test1, test2, test3 or test4. The filter
needs to corresond to this table;

test1 - a,b,c,d
test2 - e,f,g,h
test3 - i,j,k,l
test4 - m,n,o,p

So, if the first combo box is test1, then I want the second combo box to
filter a field in the recordsource for a, b, c and d.

Make sense?

Thanks.

Michael
 
you can use the values in an IN operator for your filtering. If the values
are text, you will want to enclose them in single quotes:

'a','b','c','d'

That will make it easier to build the filter in the After Update event of
the first combo:

If Not IsNull(Me.Combo1) Then
Me.Combo2.Filter = "Select SomeField From SomeTable Where IN(" &
Me.Combo1.Column(1) & ")"
Me.Combo2.Requery

Me.
 
Michael,

I think you mean Row Source, rather than recordsource.

Make a two-field table, and add data like this...
test1 a
test1 b
test1 c
test1 d
test2 e
test2 f
etc...

Then, in the query that you use for the Row Source of the second
combobox, add this table, and join its second field to the applicable
field in the original query/table. Hope that makes sense. Then you can
refer to the first combobox, as usual, in the criteria of the query, in
the first field of the new lookup table, using syntax such as...
[Forms]![NameOfYourForm]![YourFirstCombo]
 
Back
Top