The char string include #

  • Thread starter Thread starter Huayang
  • Start date Start date
H

Huayang

In access 2000, how to handle the char string including #, like this
equipment name is "1# motor". ths SQL is:

SELECT * FROM Equipment WHERE EquipName LIKE '" & tbEquipName & "*';"

but cann't retrieve equipment data.

Thanks
 
The trick is to place the wildcard character in square brackets, so Access
treats it as a literal.

This kind of thing:
SELECT *
FROM Equipment
WHERE EquipName LIKE "1[#]motor*";

So, of tblEquipName is a variable that may contain the # character:
SELECT *
FROM Equipment
WHERE EquipName LIKE """" & Replace(tblEquipName,"#","[#]") & "*""";

Of course, if you know exactly what you are looking for, you could just use
= instead of Like:
SELECT *
FROM Equipment
WHERE EquipName = "1#motor";
 
Back
Top