Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference to Form Field in Query: Searching for Like Values

Status
Not open for further replies.

Sumnor

Programmer
May 29, 2003
16
US
Hello. I have a query that references a form field as query criteria:

[Forms]![Team]![Team]

The Team field on the form allows the user to select one (1) name. An example of some of the form field values:

Sandy
John
Jennifer

The query successfully brings back all records that meet that criteria. The problem is that some of the records contain team names like:

Sandy/John
Jennifer/Sandy

I don't want to require the user to select all possible combinations where their name is referenced. I want them to be able to select their name on the form and have the query search for all records containing that name.
In other words, if the user selects 'Sandy' on the form the query results show all records that contain 'Sandy' in the team field? The results would be like:

Sandy
Sandy/John
Jennifer/Sandy

Any help/direction is greatly appreciated.
 
Thanks, Leslie - that certainly does works when entering/searching for a constant value. My question is a bit more complicated than that. I need to find a way to pass a value from a form to complete the search.
 
I figured it out - a syntax issue - and can't believe that this was so 'difficult' for me to figure out. Geesh!

Like "*" & [Forms]![Team]![Team] & "*
 
glad you got it. It's the * (or % in TSQL) that makes the LIKE clause work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top