|
Subject:
|
Using LIKE with an if statement
|
|
Posted By:
|
bloofrog
|
Post Date:
|
9/30/2005 7:30:42 PM
|
I have a field in an Access2000 DB that I would like to query using LIKE
<%IF(RecordSet.Fields("fieldname") LIKE %PA% )Then%>
This throws error messages all over the place, mostly Sub or Function not defined
Can anyone tell me how to do this correctly?? TIA
|
|
Reply By:
|
madda
|
Reply Date:
|
10/3/2005 2:49:03 PM
|
try putting single quotes around the percentages like below
<%IF(RecordSet.Fields("fieldname") LIKE '%PA%' )Then%>
|
|
Reply By:
|
Steven
|
Reply Date:
|
10/4/2005 12:11:42 AM
|
Or given that you shouldn't be using SQL at this point, becuause you're querying the recordset not the database, perhaps this would be better:
<% If InStr(RecordSet.Fields("fieldname"), "PA")>0 Then %>
I am a loud man with a very large hat. This means I am in charge
|
|
Reply By:
|
apple88
|
Reply Date:
|
7/7/2007 9:22:38 PM
|
Hi,
Do you know how to pull many item using "LIKE"
Below is the example but got error
Dim sSqlMaster, sSqlLike sSqlMaster = ""SELECT DISTINCT TOP 65535 T1.A,T1.B " & _ "FROM Table1 " & _ "WHERE T1.A "
For i = 0 to i =count step 1 sSqlLike = sSqlLike & "LIKE '" & part[i]& "%' AND T1.A " Next
sSqlMaster = sSqlMaster & Left(sSqlLike, (Len(sSqlLike) - 1
apple
|