[AccessD] Like Operator SQL Syntax

Paul M. Jones pjones at btl.net
Thu Jun 5 10:36:37 CDT 2003


I believe the wildcards have to be included in single quotes:

Try
strSQL = "SELECT tblCustomers.CustomerID, "  & _
                 " [tblCustomers]![CustomerNumber] & '-' & 
[tblCustomers]![CustomerSite] AS CustCode, " & _
         " tblCustomers.CustomerName, " & _
         " tblCustomers.Address1 & ' ' &  "tblCustomers.Address2 & ' ' & 
tblCustomers.Address3 & ' ' & tblCustomers.Postcode AS Address,  " & _
         " tblCustomers.DepotID" & _
         " FROM tblCustomers " & _
                 " WHERE tblCustomers.CustomerName) Like '%" & strInput & 
"%' "  & _
                 " ORDER BY tblCustomers.CustomerName"

At 08:13 AM 6/5/2003 -0700, you wrote:
>strSQL = "SELECT tblCustomers.CustomerID, " _
>             & "[tblCustomers]![CustomerNumber] & '-' & 
> [tblCustomers]![CustomerSite] " _
>             & "AS CustCode, tblCustomers.CustomerName, 
> tblCustomers.Address1 & ' ' & " _
>             & "tblCustomers.Address2 & ' ' & tblCustomers.Address3 & ' ' 
> & " _
>             & "tblCustomers.Postcode AS Address, tblCustomers.DepotID 
> FROM tblCustomers " _
>             & "WHERE (((tblCustomers.CustomerName) Like % + " _
>             & strInput & " + %)) " _
>             & "ORDER BY tblCustomers.CustomerName;"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030605/b0517168/attachment-0001.html>


More information about the AccessD mailing list