Wildcard Filter Code

D

DeVille

I have this filter button which filters my records by
customer name, it works well but I have to type the whole
customer name, I'm trying to change my code so that it
works if the user types only the first few letters of the
customer's name(I think its called a wildcard) eg Pete
instead of Peter
Here is the 'Me' part of the code I have 'on click' in
the button procedure at the moment which works if I type
the whole name

Me.Filter = "[CustomerName] like [Enter Customer Name]"
Me.FilterOn = True

This is something like what I think maybe the 'Me' part
of the code should look like

Me.Filter = ((([CustomerName.*]) Like [Enter Customer
Name] & "*"))
Me.FilterOn = True

If anyone can explain how to do this thanks in advance
 
F

Fredg

Try this.
Me.Filter = "[CustomerName] Like '" & InputBox("Enter CustomerName") & "*'"
Me.FilterOn = True

Note the placement of the 2 single quotes above.
Like ' " & InputBox("Enter CustomerName") & "* ' "
 
D

DeVille

Thanks it works well

-----Original Message-----

Try this.
Me.Filter = "[CustomerName] Like '" & InputBox("Enter CustomerName") & "*'"
Me.FilterOn = True

Note the placement of the 2 single quotes above.
Like ' " & InputBox("Enter CustomerName") & "* ' "

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


DeVille said:
I have this filter button which filters my records by
customer name, it works well but I have to type the whole
customer name, I'm trying to change my code so that it
works if the user types only the first few letters of the
customer's name(I think its called a wildcard) eg Pete
instead of Peter
Here is the 'Me' part of the code I have 'on click' in
the button procedure at the moment which works if I type
the whole name

Me.Filter = "[CustomerName] like [Enter Customer Name]"
Me.FilterOn = True

This is something like what I think maybe the 'Me' part
of the code should look like

Me.Filter = ((([CustomerName.*]) Like [Enter Customer
Name] & "*"))
Me.FilterOn = True

If anyone can explain how to do this thanks in advance


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top