Wild card not working in Access 2010 query

J

JayTee

Hi all,
I am wondering if anyone out there knows why the wild card (*) will not work
in an MS Access 2010 query.

I tried, as I have for years, to enter a criteria in a query as follows:
Like "*" & [Forms]![FormName]![FieldName] & "*"
And it creates this
ALike "*" & [Forms]![FormName]![FieldName] & "*" and then won't work
Please help someone as I am at my wits end.
Thanks in advance

JayTee
 
D

Douglas J. Steele

Depending on how you're using it, you may need to use % as the wildcard, not
*.
 
J

John W. Vinson

Hi all,
I am wondering if anyone out there knows why the wild card (*) will not work
in an MS Access 2010 query.

I tried, as I have for years, to enter a criteria in a query as follows:
Like "*" & [Forms]![FormName]![FieldName] & "*"
And it creates this
ALike "*" & [Forms]![FormName]![FieldName] & "*" and then won't work
Please help someone as I am at my wits end.
Thanks in advance

JayTee

Sounds like you've set the database's properties to use SQL/92 format queries
(not sure just how it phrases it). The ALike is the clue. ALike is equivalent
to the SQL/Server syntax of LIKE, and uses % rather than * as the "match any
string" wildcared (also it uses _ rather than ? as the match a single
character). See the online Help for "ALIKE".
 
D

David W. Fenton

I am wondering if anyone out there knows why the wild card (*)
will not work in an MS Access 2010 query.

I tried, as I have for years, to enter a criteria in a query as
follows: Like "*" & [Forms]![FormName]![FieldName] & "*"
And it creates this
ALike "*" & [Forms]![FormName]![FieldName] & "*" and then won't
work Please help someone as I am at my wits end.
Thanks in advance

Because you're using ALIKE instead of LIKE. ALIKE exists to allow
you to use SQL Server compatible wildcards, in which case you'd use
% in place of * and _ in place of ?.
 
D

David W. Fenton

Hi all,
I am wondering if anyone out there knows why the wild card (*)
will not work in an MS Access 2010 query.

I tried, as I have for years, to enter a criteria in a query as
follows: Like "*" & [Forms]![FormName]![FieldName] & "*"
And it creates this
ALike "*" & [Forms]![FormName]![FieldName] & "*" and then won't
work Please help someone as I am at my wits end.

Sounds like you've set the database's properties to use SQL/92
format queries (not sure just how it phrases it). The ALike is the
clue. ALike is equivalent to the SQL/Server syntax of LIKE, and
uses % rather than * as the "match any string" wildcared (also it
uses _ rather than ? as the match a single character). See the
online Help for "ALIKE".

ALIKE works even when you don't have SQL 92 mode turned on.

I've never quite figured out what purpose it serves, to be honest,
as all it does is allow you to use the SQL Server-compatible
wildcards. I don't know if it's compatible with other SQL dialects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top