Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The like operator..?

Status
Not open for further replies.

kenjoswe

Technical User
Sep 19, 2000
327
SE
Hi all,

What is the correct syntax of the SQL-operator 'like'?

I'm want to use it something like:

.RowSource="Select * from Customer where CustId like " & Me.TextBox1 & "*"

Something is wrong with the above syntax but I cannot figure out what it is.

/Kent J.
 
Sorry. that's not all! :p
You should use single quotes too.

ex:
"Select * from Customer where CustId like '" & Me.TextBox1 & "%'"
 
johpje,

Have you tried that?
I can't even get this to work:
.Rowsource= "Select * from Customer where CustId like 2%"
but this work:
Select * from Customer where CustId =279"

/Kent J.
 
Kent did you try

"Select * from Customer where CustId like Like "2" & "*"

Access doesn't recognise % as a wild card * is the wildcard

to use a textbox you need
"Select * from Customer where CustId like '" & Me.TextBox1 & "'" & "*"

 
braindead2,

Well I've tried:
.RowSource = "Select * from Customer where CustId like 2*"

.RowSource = "Select * from Customer where CustId like '" & Me.TextBox1 & "'*"

CustId is numeric (Autonumber).

Nothing seems to work

/Kent J.



 
I created a table named customers created a field customerid field is autonumber and a few other field name etc..
I then created a form

this works when I use 2
List0.RowSource = "SELECT *FROM customer WHERE customerid Like '2' & '*'"

this works when I use a textbox
List0.RowSource = "SELECT * FROM customer WHERE customerid Like '" & Me.Text1 & "' & '*'"

the syntax is essential here.
good luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top