Doesn't work Like "*" [Forms]![SearchCriteria]![StrAddress] "*"

B

Bill Wilson

I'm using a Form to have the user enter/select search criteria, eg a
property's address, then use the query criteria expression: Like "*"
[Forms]![SearchCriteria]![StrAddress] "*" , but the query returns no records
(yes, there are valid records to be found). How do I use a control in a Form
to query these records?
 
A

Amy Blankenship

Without seeing exactly where/how you're entering this, have you tried Like
"*" & [YourControlAddress] & "*"

?

HTH;

Amy
 
C

Carl Rapson

Assuming the [StrAddress] field is text, you might need to put quotes around
the string:

Like " '*" & [Forms]![SearchCriteria]![StrAddress] & "*' "

I left spaces before and after the single quotes to show where they belong.
Note also the & for concatenating the strings together.

HTH,

Carl Rapson
 
J

John Vinson

Assuming the [StrAddress] field is text, you might need to put quotes around
the string:

Like " '*" & [Forms]![SearchCriteria]![StrAddress] & "*' "

I left spaces before and after the single quotes to show where they belong.
Note also the & for concatenating the strings together.

HTH,

Carl Rapson

Bill Wilson said:
I'm using a Form to have the user enter/select search criteria, eg a
property's address, then use the query criteria expression: Like "*"
[Forms]![SearchCriteria]![StrAddress] "*" , but the query returns no
records
(yes, there are valid records to be found). How do I use a control in a
Form
to query these records?

Actually it's simpler than that. Bill, you didn't use the & operator
which concatenates strings - Access has no idea what to do with the
form reference.

A criteria expression

LIKE "*" & [Forms]![SearchCriteria]![StrAddress] & "*"

will use the & concatenation operator to construct a criteria string

*Main*

if the user types Main into the form control named strAddress.

John W. Vinson[MVP]
 
Top