LIKE operator in SQL query

enigmajl

New member
Local time
Today, 07:10
Joined
Aug 6, 2004
Messages
8
here's my sql statement.

condition = txtQueryBySoftware

strSQL = "SELECT [Report].[RUser], [Item].[IDevice], [Item].[IValue], [Item].[ID], [Report].[ID] FROM Report INNER JOIN Item ON [Report].[ID]=[Item].[ReportID]

WHERE (((Item.IPage) = 'Installed Programs')
And ((Item.IDevice) Like """ & condition & """));"

i tried adding the * and % but m not too sure where to add those wildcard characters
how to i change it such that it can return a range of answers?
eg. itype "visio" it shoud return me
MS visio 2000
MS visio 97 and so on.

thanks a million!
 
Code:
Dim strSQL As String
   
strSQL = "SELECT [Report].[RUser], [Item].[IDevice]," & _
         " [Item].[IValue], [Item].[ID], [Report].[ID]" & _
         " FROM Report INNER JOIN Item ON [Report].[ID]=[Item].[ReportID]" & _
         " WHERE Item.IPage = 'Installed Programs'" & _
         " And Item.IDevice Like """ & "*" & Me.txtQueryBySoftware & "*" & """;"
 
Thank you so much for replying!!!!
THank you thank you.

However it still doesnt work.
it gives me an item not found error.
and the msg box i printed out of the sql string is:

SELECT [Report].[RUser], [Item].[IDevice], [Item].[IValue], [Item].[ID], [Report].[ID] FROM Report INNER JOIN Item ON [Report].[ID]=[Item].[ReportID] WHERE (((Item.IPage) = 'Installed Programs') And ((Item.IDevice) Like "*visio*";

any ideas?
Thanks thanks!!!
 
You need two )) at the end in front of ;

SELECT [Report].[RUser], [Item].[IDevice], [Item].[IValue], [Item].[ID], [Report].[ID]
FROM Report INNER JOIN Item ON [Report].[ID]=[Item].[ReportID]
WHERE ((([Item].[IPage])='Installed Programs') And (([Item].[IDevice]) Like "*visio*"));


Where do the brackets come from? I didn't use any brackets in the code.
.
 

Users who are viewing this thread

Back
Top Bottom