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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wild card in where clause

Status
Not open for further replies.

FoxGolfer

Programmer
Jul 30, 2002
100
US
I need to have a wild card in a where clause. I'm looking for part numbers that have a leading blank at the beginning of the field. (Most, not all; it's main frame data, and it's not going to change.) Currently, I have a SQL statement that ends with the following where:
..."WHERE ListPrice.PN like '" & strPartNo & "'"
I had = rather than like before I got the latest download. Changing to like still doesn't find the part. Using QBE, I can find it by entering a space (" 1234567") or if I add an asterisk ("*1234567). What do I need to do the change my existing where clause to be able to find the part number?
Thanks in advance,
Tom
 
Do you mean:
..."WHERE ListPrice.PN like '*" & strPartNo & "'"
Or perhaps:
..."WHERE ListPrice.PN like ' " & strPartNo & "'"
?

 
I'm sorry, I don't understand your response. The Where clause I posted is a copy/paste from the code.
Are you saying to add the * between the ' and "?
 
I'm sorry, I don't understand your response. The Where clause I posted is a copy/paste from the code.
Are you saying to add the * between the ' and "? I tried that and it didn't work.
 
In what way does it not work? I have tried:
strSQL = "Select * From Members Where Firstname Like '*ar*'"
Set rs = CurrentDb.OpenRecordset(strSQL)
Which gives me Mary, Martin, Tara etc, as you would expect.

ListPrice.PN is text, isn't it?
 
What is the field name? PN or strPartNo??

Is this what you want...

Where ListPrice.PN Like " *"

OR

Where ListPrice.PN Like " "&"*"

 
Remou,
ListPrice.PN is text.
Lillibeth,
The field name is PN.

What I want is *PN but I can't figure out how to write it.
I did get it to work differently; I added the trim() to the code:

"SELECT Trim([ListPrice.PN]) AS P, .......
...."WHERE Trim([ListPrice.PN]) = '" & strPartNo & "'"

This works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top