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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search from two text boxes 1

Status
Not open for further replies.

mrkuosea

MIS
Nov 24, 2011
20
0
0
US
I have set up a form with two text boxes which feed the search words in a query.

The first text box is mandatory. The second text box is optional, it only appears if the user clicks on a check box in the form.

This is how it is supposed to work: The user will enter a single word or string of characters in the first textbox and click a command button which will run the query and generate a report based on the query.

If the user wishes to use a second string with the first string, he/she will click the checkbox, the second textbox appears and he/she can enter the second string and click on the command button which will run the query and generate a report based on the query.

The report will contain different records with the search words.

I tried using the following statement in the query criteria but it doesn't work. Apparently it is "too complex" (according to the error message Access returns).

IIf([Forms]![frmMultiSearch]![chkaddsearch]=0,([tblCust].[lookhere]) Like "*" & [Forms]![frmMultiSearch]![searchBox1],([tblCust].[lookhere]) Like "*" & [Forms]![frmMultiSearch]![searchBox1] & "*" Or ([tblCust].[lookhere]) Like "*" & [Forms]![frmMultiSearch]![searchBox2] & "*")

Is there another way I can do this?

Please help!

Thank you for your help.
 
In the SQL view pane use the following WHERE clause:
WHERE (tblCust.lookhere Like "*" & [Forms]![frmMultiSearch]![searchBox1] OR (tblCust.lookhere Like "*" & [Forms]![frmMultiSearch]![searchBox2] & "*" AND [Forms]![frmMultiSearch]![chkaddsearch]<>0))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top