Wildcard Filter Code

  • Thread starter Thread starter DeVille
  • Start date Start date
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
 
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") & "* ' "
 
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


.
 
Back
Top