Filter a form when typing in a text box

I'm trying to filer records being displayed in a form when the user types in a text box.  This what I have in the onchange event of the form but if I try to type "123" as an example, it replaces the "1" with a "2" when I type the "2".

I also want it to display ALL records that contain "123" in the street address.


    Me.Filter = "StreetAddress like '" & Me.txtFindStreetAddress.Text & "*'"
    Me.FilterOn = True
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
use the onchange event..read your input and filter your data with LIKE
SteveL13Author Commented:
I don't understand.  I am using the onchange event but it isn't working as I stated.
Dale FyeOwner, Developing Solutions LLCCommented:
OK, so you should be using the textbox OnChange event,

Where is the txtFindStreetAddress control located on your form (header)?  If not that is where it should be.

Private Sub  txtFindStreetAddress_Change

     Me.Filter = "StreetAddress like '*" & Me.txtFindStreetAddress.Text & "*'"
     Me.FilterOn = True 

End Sub

Open in new window

But doing this in the ChangeEvent of a textbox can be very demanding on the database, as the form will be filtered after every key stroke and depending on the size of the dataset, this could be rather annoying.  Instead, I would use a button next to the textbox, and actually modify the SQL for the form when the button is clicked.  This way, the form isn't constantly trying to get refiltered.  Furthermore, it will limit the demand on the network, by only returning rows to the recordset which meet your entered text string.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
I went with a command button per you suggestion.  Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.