Michael said:
I have a textbox TxtFilter that I use to filter a datasheet using the
following query:
"SELECT * from TProduct WHERE TProduct.ArtNo LIKE '*" & TxtFilter & "*'"
However, I cannot include character # in the TxtFilter because it is used to
delimiter dates in a query.
What can I do?
While it's true that # is the date deliminator, it won't be
interpreted that way in this context.
Since your text box is supplying part of the pattern to the
LIKE operator, you have the benefit(?) of being able to use
wildcard characters in the string in the text box. # is a
wildcard character that matches a decimal digit. There are
other wildcards such as *, ? and [ ] See Wildcard
Characters in Help for details.
If you want to match a character that is also a wildcard,
then you should enclose it in [ ]. For example, if you want
to filter for records that conatin XY#12 within a field,
then you should enter XY[#]12 in the text box.
This kind of thing is both a curse and a blessing. While it
can be very confusing to users, it does provide them with a
very powerful search feature.
If you want to eliminate this kind of thing, then you'll
have to check the string from the text box and replace any
wildcards with whatever it takes to neutralize them. Iin
your example, you could use:
. . . TProduct.ArtNo LIKE '*" &
Replace(TxtFilter,"#","[#]") & "*'"