Filtering

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

Guest

I am trying to use a textbox to filter a form. I want it to be able to filter each time I type a letter. For example, if I had a table of states, when 'c' is typed in to the textbox, all states that begins with the letter 'c' would show up. When I type in 'a' after the 'c', which makes the input "ca", then only "California" would show up. Anyone knows how to do that in both Access 97 and Access 2000?

Thanks a million in advance.
 
Anthony said:
I am trying to use a textbox to filter a form. I want it to be able to filter each time I type a letter. For example, if I had a table of states, when 'c' is typed in to the textbox, all states that begins with the letter 'c' would show up. When I type in 'a' after the 'c', which makes the input "ca", then only "California" would show up. Anyone knows how to do that in both Access 97 and Access 2000?


Place the unbound text box in the form's header section.
Use code like the following in the text box's AfterUpdate
event procedure:

Me.Filter = "statefield LIKE ""*" & Me.thetextbox & """"
Me.FilterOn = True

If your form is more than a simple form, then it may be more
reliable to reset the form's record source instead of using
the less than perfect Filter property:

Me.RecordSource = "SELECT statefield FROM statestable " _
& "WHERE statefield LIKE ""*" & Me.thetextbox & """"
 
Back
Top