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

Creating a Keyword Search in Access

Status
Not open for further replies.

jaxx75

Technical User
Jun 20, 2006
10
0
0
US
How do I go about doing this?

If possible, not just keyword, but any field that I have, I want to find some things mentioned in the description of the field also. :)

Thanks a lot,
-Jackson
 
Hi Jaxx75,

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.

Hope that helps.

Bob :)
 
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.

Global Search and Filter
thread702-1213703
 
Thanks for the help, but one more question, and I know its simple, :p

How do you bind this function to a table? I just picked up Access and I can't seem to find a way to do it!

Please forgive my noobieness :)

-Jackson
 
Hi again Jaxx75,

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.

Let me know if you have any further questions.

Bob
 
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.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top