Using Wildcards from a form in a query's criteria

T

The parawon

I'm using the expression in a Query to return the data that someone will
enter into a form's text box. The criteria is returned properly and the
reports run fine when the data entry person types the exact name. For
example, if the entry person typed "Mike" in the form, the make table query
would run and return all records with Mike. If the data entry person enters
"Mi*" to get anything that sounds like Mike or Michelle, nothing no records
are returned. In the expression builder, I am only referencing the text box,
not any of it's properties. I'm simply using:
Forms![ContactPerson]![NameTextBox] in the criteria field of the make-table
query.

Any help in the right direction is appreciated.
 
F

fredg

I'm using the expression in a Query to return the data that someone will
enter into a form's text box. The criteria is returned properly and the
reports run fine when the data entry person types the exact name. For
example, if the entry person typed "Mike" in the form, the make table query
would run and return all records with Mike. If the data entry person enters
"Mi*" to get anything that sounds like Mike or Michelle, nothing no records
are returned. In the expression builder, I am only referencing the text box,
not any of it's properties. I'm simply using:
Forms![ContactPerson]![NameTextBox] in the criteria field of the make-table
query.

Any help in the right direction is appreciated.

If you are using a wildcard you must use the Like keyword.
Change your query's criteria to one of the following.

To find records in a field that begin with the entered text:
Like Forms![ContactPerson]![NameTextBox] & "*"

To find records in a field that end with the entered text:
Like "*" & Forms![ContactPerson]![NameTextBox]

To find records in a field that have the entered text anywhere in the
field:
Like "*" & Forms![ContactPerson]![NameTextBox] & "*"
 
G

Guest

You can set your query criteria to Like Forms!
[ContactPerson]![NameTextBox]. the eu can then enter
wild cards in the places they want. I then use code to
set the forms field value to * if it is null. this will
return all rows.
-----Original Message-----
I'm using the expression in a Query to return the data that someone will
enter into a form's text box. The criteria is returned properly and the
reports run fine when the data entry person types the exact name. For
example, if the entry person typed "Mike" in the form, the make table query
would run and return all records with Mike. If the data entry person enters
"Mi*" to get anything that sounds like Mike or Michelle, nothing no records
are returned. In the expression builder, I am only referencing the text box,
not any of it's properties. I'm simply using:
Forms![ContactPerson]![NameTextBox] in the criteria field of the make-table
query.

Any help in the right direction is appreciated.

If you are using a wildcard you must use the Like keyword.
Change your query's criteria to one of the following.

To find records in a field that begin with the entered text:
Like Forms![ContactPerson]![NameTextBox] & "*"

To find records in a field that end with the entered text:
Like "*" & Forms![ContactPerson]![NameTextBox]

To find records in a field that have the entered text anywhere in the
field:
Like "*" & Forms![ContactPerson]![NameTextBox] & "*"
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 

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