Filtering using a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to filter the records of a table displayed in a form based on a
combo box whose record source matches the values of one of the fields in the
form.

does anyone know how to do this?
 
Irvine said:
I am trying to filter the records of a table displayed in a form
based on a combo box whose record source matches the values of one of
the fields in the form.

does anyone know how to do this?

In the AfterUpdate event of the ComboBox...

(if field is numeric)
Me.Filter = "[FieldName] = " & Me.ComboBox
Me.FilterOn = True

(if field is text)
Me.Filter = "[FieldName] = '" & Me.ComboBox & "'"
Me.FilterOn = True
 
Just an aside...
In the AfterUpdate event of the ComboBox...
(if field is numeric)
Me.Filter = "[FieldName] = " & Me.ComboBox
Me.FilterOn = True
How do I put this kind of code in the AfterUpdate? I know of only two ways
- VB sub
- write a macro (SetValue etc...), and attach it to the form property (and
end up with dozen of macros)

Both ways are a little too cumbersome for 2 lines of code as above.

Any other way to do that? can I just write code in the property field?
 
Back
Top