I have done this successfully. I have created a form (Info Search) that the users bring up to enter their search word or phrase. Then I have the following code attached to the "On Click" event of an OK button:
DoCmd.OpenForm "Info Results", acNormal, "", "[Narrative] Like '*' & [Forms]![Info Search]![Narrative] & '*' Or [Subject] Like '*' & [Forms]![Info Search]![Narrative] & '*'", acReadOnly, acNormal
DoCmd.Close acForm, "Info Search"
It searches for the the entire main narrative area and the subject line for the criteria entered. It then displays a list of subject lines of records that meet the criteria in a form (Info Results) for the user to review. The last line closes the search form so the user does not have to worry about that. I also have a "View" button on the results page so the user can click that to view the entire record.
If you would like the keyword search to be part of the active form and not a pop-up, this solution worked for me. I have a text box on the form and the user enters the keyword, could even be a partial "SAN" would bring up any records that have San in it like San Francisco, San Jose, Santa Clara regardless of which field they reside in.
For my post, the search page that I have does not actually have to be bound to the table. The results form is already bound and that is what it is actually using to display the results. Essentially, the results form is re-opening with your new criteria everytime you do a search.
btw - the method that sxschech is talking about is also very good. He is essentially doing the same thing I am but doing it on one form. My users wanted the seperate form. It is a matter of preference.
Sorry it took so long to get back to you. Things have been a bit hectic here.
Create a form called "Info Search" that is not bound to any tables. Put a non-bound field on the form labelled and named "Narrative". Then add a button to the form and add the following "event procedure" to the OnClick event.
DoCmd.OpenForm "Info Results", acNormal, "", "[Narrative] Like '*' & [Forms]![Info Search]![Narrative] & '*' Or [Subject] Like '*' & [Forms]![Info Search]![Narrative] & '*'", acReadOnly, acNormal
DoCmd.Close acForm, "Info Search"
Replace the [Forms]![Info Search]![Narrative] with you form name and fields that you want to display the results in. My code above currently only searches the two fields. If you want to search more than that, just add another Or within the double quotes and the fields you want to search.
Hope this helps. If you need further assistance, please let me know.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.