ApplyFilter question

quiksilver1804

New member
Local time
Yesterday, 23:34
Joined
Jun 29, 2006
Messages
8
I have a form with multiple filters and they are applied by a "Filter records" button. One of the filter's is for a name of a company. The problem i have is it does a wildcard search automatically.

IE:

"Starbucks" is entered will actually do a filter of Starbucks*

The reason for that is because our locations have the store number on there and it is like this:

Starbucks #1234

The # sign is throwing me off on my filter. If is just "Starbucks", it will list all the locations with the store number, however, if they know the store number and enter "Starbucks #1234" it won't work since the # is in there and i know you can't use # on a normal filter. Is there a way to escape the char if it is included in the string?

Code:
Code:
Name = Forms!FCD_AccountLookup!cmbName
FilterName = "CANAMC Like '" & Name & "*'"
 
If you just want to remove the # sign, use this code:
Code:
Name = Forms!FCD_AccountLookup!cmbName
Name = Left(Name, Instr(Name, "#") - 1) & Right(Name, Len(Name) - InstrRev(Name, "#"))
FilterName = "CANAMC Like '" & Name & "*'"

That will convert your value of Name to the same value without the # sign in it.
 

Users who are viewing this thread

Back
Top Bottom