Reputation: 886
I am running the following query in Access VBA
Case "Customer Name"
strSQL = "SELECT CustomerID, Customer_Name, Industry FROM TBLCUSTOMERSNEW WHERE ucase(Customer_Name) Like '*" & UCase(tempStr) & "*'" & " ORDER BY Customer_Name"
Me.lstSearchResults.ColumnCount = 4
Me.lstSearchResults.ColumnWidths = "1cm;7cm;12cm;"
Is it possible to amend this query so that when the value being searched for (tempStr
) contains a "&" the records returned also contain records where customer_name
contains "and", and vice versa?
Upvotes: 0
Views: 79
Reputation: 32642
Just thought up a simple alternative not using any IF
logic for you.
SELECT customerid,
customer_name,
industry
FROM tblcustomersnew
WHERE Replace(Ucase(customer_name), "&", "AND") LIKE '*" & Replace(UCase(tempStr), "&", "AND") & "*'" & "
ORDER BY customer_name
That should do it.
Upvotes: 2