By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

not liking LIKE so much any more

P: n/a
Have used LIKE in SQL statements frequently in past with the wildcard (*) in
previous databases.

For example, I have made recordset from the following SQL string:

strSQL = "SELECT [PatientDemographics].[PatientID],
[PatientDemographics].[LASTNAME], [PatientDemographics].[FIRSTNAME],
[PatientDemographics].[Dateofbirth],
[PatientDemographics].[SocialSecurityNumber], [PatientDemographics].[Age] " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )) " _
& "ORDER BY [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME];"

This SQL string has worked well for me in the past. The first part of last name
is inserted into variable LN and then using the wildcard the appropriate
records are found (LN*). I believe the syntax for doing this is correct but
"Like """ & LN & "*"": no longer works on a new database.

Is this because I am missing a reference library for the wild card. I also am
now using ADO recordsets rather than DAO. Does that cause a problem?

Thanks for the help in advance.

Mike

Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
ADO's SQL does use different characters -- I believe the wildcard character
is "%" as it is in SQL Server.

Larry Linson
Microsoft Access MVP

"MFS 43" <mf***@aol.com> wrote in message
news:20***************************@mb-m14.aol.com...
Have used LIKE in SQL statements frequently in past with the wildcard (*) in previous databases.

For example, I have made recordset from the following SQL string:

strSQL = "SELECT [PatientDemographics].[PatientID],
[PatientDemographics].[LASTNAME], [PatientDemographics].[FIRSTNAME],
[PatientDemographics].[Dateofbirth],
[PatientDemographics].[SocialSecurityNumber], [PatientDemographics].[Age] " _ & "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )) " _
& "ORDER BY [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME];"

This SQL string has worked well for me in the past. The first part of last name is inserted into variable LN and then using the wildcard the appropriate
records are found (LN*). I believe the syntax for doing this is correct but "Like """ & LN & "*"": no longer works on a new database.

Is this because I am missing a reference library for the wild card. I also am now using ADO recordsets rather than DAO. Does that cause a problem?

Thanks for the help in advance.

Mike

Nov 13 '05 #2

P: n/a
"MFS 43" <mf***@aol.com> wrote in message
news:20***************************@mb-m14.aol.com...
Have used LIKE in SQL statements frequently in past with the wildcard (*) in previous databases.

For example, I have made recordset from the following SQL string:

strSQL = "SELECT [PatientDemographics].[PatientID],
[PatientDemographics].[LASTNAME], [PatientDemographics].[FIRSTNAME],
[PatientDemographics].[Dateofbirth],
[PatientDemographics].[SocialSecurityNumber], [PatientDemographics].[Age] " _ & "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )) " _
& "ORDER BY [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME];"

This SQL string has worked well for me in the past. The first part of last name is inserted into variable LN and then using the wildcard the appropriate
records are found (LN*). I believe the syntax for doing this is correct but "Like """ & LN & "*"": no longer works on a new database.

Is this because I am missing a reference library for the wild card. I also am now using ADO recordsets rather than DAO. Does that cause a problem?


ADO uses % as the wildcard character, not *. (It also uses _ instead of ?)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Nov 13 '05 #3

P: n/a
Larry Linson wrote:
ADO's SQL does use different characters -- I believe the wildcard character
is "%" as it is in SQL Server.


Your belief is valid :-)

For general interest, the ? (single character wildcard) In Access is the
underscore character in SQL Server and ADO. I don't know if ADO handles
escapes the same way as SQL Server, e.g. in SQL Server

Like 'Americani[sz]e' would find 'Americanize' and 'Americanise'

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #4

P: n/a
That's obviously my problem. Thanks for the help.
Nov 13 '05 #5

P: n/a
Thanks for the response.

Mike
Nov 13 '05 #6

P: n/a
That is obviously my problem. Thanks for taking the time.

Michael S

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.