I want to make a LIKE statement with a variable, when I do it like this, it doesn't work:
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE ''" & searchrel
What is the right statement with a variable??
Remco Ploeg
[email protected]
Printable View
I want to make a LIKE statement with a variable, when I do it like this, it doesn't work:
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE ''" & searchrel
What is the right statement with a variable??
Remco Ploeg
[email protected]
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE " & searchrel
or
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE '%" & searchrel & "%'"
or
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE ''%" & searchrel & "%''"
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
this is working, but now he shows the records that contains the variable. For example
variable = k
kampa company
esko company
He display the two record because there is a k in. I want only the first letter
Remco Ploeg
[email protected]
This should do the trick
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE '" & searchrel & "%'"
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook