How to search using multiple keywords at the same time? (1 Viewer)

MiikkaT

New member
Local time
Today, 08:53
Joined
Dec 23, 2007
Messages
4
I would like to make an Access database for my collection of scientific papers. From that database I should be able to find articles using descriptive keywords. The problem is I haven’t figured out how I could search for the articles needed using multiple keywords at the same time (eg. papers that fill the criteria: <keyword a> AND <keyword b> AND <keyword c>).

What kind of tables and queries I have to create to do that?

Thanks,
-MiikkaT
 

Sum Guy

Registered User.
Local time
Yesterday, 22:53
Joined
Nov 19, 2006
Messages
310
How about adding three fields to your table:
Keyword1, Keyword2 and Keyword3.
Then add your keywords in order of importance when you enter your paper into the database.

Create a search form where you can enter up to 3 keywords. In the criteria of your query under each of the Keyword fields tell it to search for the keyword on the form.

I have been using this system with great success. The only problem is you have to be consistent with your use of the keywords. I use a separate table with keywords and combo boxes on both the entry and the search forms for consistency.
 

MiikkaT

New member
Local time
Today, 08:53
Joined
Dec 23, 2007
Messages
4
Thanks Sum Guy,
I hadn't thought it that way. Using different keyword fields might really be a viable option in my case. However, I would prefer solution where I don't need to care about hierarchy of the keywords.

MiikkaT
 

ajetrumpet

Banned
Local time
Today, 00:53
Joined
Jun 22, 2007
Messages
5,638
Miikka,

You might find post #8 in the following thread helpful...

http://www.access-programmers.co.uk/forums/showthread.php?t=139982

And a second idea:

Aren't you answering your own question with the following quote...??
The problem is I haven’t figured out how I could search for the articles needed using multiple keywords at the same time (eg. papers that fill the criteria: <keyword a> AND <keyword b> AND <keyword c>).
I would think that the answer to your question lies with the AND operator, wouldn't you?
 

evanscamman

Registered User.
Local time
Yesterday, 22:53
Joined
Feb 25, 2007
Messages
274
Multiple Keyword search

I have a form that searches through Item's names based on 2 keyword boxes.
Here's the criteria in my query:

Is Null Or Like "*" & [Forms]![frmItemView]![SearchPhrase1] & "*" And Like "*" & [Forms]![frmItemView]![SearchPhrase2] & "*"

This will show all records when both keywords are blank, and filter records using the 2 keywords otherwise.

Hope this helps,
Evan
 

Cosmos75

Registered User.
Local time
Today, 00:53
Joined
Apr 22, 2002
Messages
1,281
MiikkaT,

Just curious, are you only going to allow up to 3 criteria?
:confused:

Or are you trying to handle an unspecified number of criteria?
:eek:

Am I correct in assuming that you have at least three tables; i.e. one for papers, one for keywords, and one for assigning multiple keywords to papers?

tblPapers
PaperID [PK]
strTitle

tblKeywords
KeywordID [PK]
strKeyword

tblPaperKeywords
PaperID [FK]
KeywordID [FK]

Are you also trying to search the test of the paper titles?
 

MiikkaT

New member
Local time
Today, 08:53
Joined
Dec 23, 2007
Messages
4
Yes, that’s correct. I have three tables just as you assumed, because based on what I have read elsewhere that’s thee solution. Initially I thought that using AND-operator would be obvious way to do the queries, but I haven’t figured out how to implement that kind of queries using the table design I have. I would really prefer a system where I can use unspecified number of keywords: sometimes I would use just two (or even one), sometimes four. It all depends how specific sort of article I’m searching for.
 

ajetrumpet

Banned
Local time
Today, 00:53
Joined
Jun 22, 2007
Messages
5,638
I would really prefer a system where I can use unspecified number of keywords: sometimes I would use just two (or even one), sometimes four. It all depends how specific sort of article I’m searching for.
If that's the case, just use the system that Evan gave you two posts ago. Either that, or look here for Jon K's QBF technique.

From what you say, ideally you would use this format if you have controls in which you are entering your search words:
Code:
WHERE (([field1] = forms!searchform!controlname1 OR
   forms!searchform!controlname1 Is null) AND

([field2] = forms!searchform!controlname2 OR
   forms!searchform!controlname2 Is null) AND
[B][U]
...etc, etc, for each control that can contain a search word in it)[/U][/B]
But, if you don't have controls on the form where you are inserting separate words into separate controls, and you just want to enter any number of words into one parameter search prompt, then use this:
Code:
WHERE [fieldOfYourChoice] = "*" & [parameterstring] & "*"
>>>>>Important things to note about wildcard searches with parameter strings<<<<<

Example I'm using: Criteria Field Value = "Hello World"
Parameter String = "orl"​


1) If criteria is: "*" & [ParameterString] & "*", the search will return any record with the Criteria Field Value in it.

2) If criteria is: "*[ParameterString]*" , the search will not return any record with the Criteria Field Value in it, but it will return records with one-string field values that contain the sequence of characters "orl" in it. Example: If the field value was "World" instead of "Hello World", you would get that record returned.

Does this help you understand the process of wildcarding your searches better?
 

Cosmos75

Registered User.
Local time
Today, 00:53
Joined
Apr 22, 2002
Messages
1,281
Whipped up a quick example of using a multiple-select listbox to change a query's SQL statement. Basically I'm changing the arguments for IN part of the WHERE clause.

The ChangeQdefSQL() function is not required (you can create your own way to do it) but since I already had something that did the job, I went ahead and used it.

It would be nice to be able to search by author, year, journal and other criteria. I may want to build something like this for myself when I get some free time!
:D

Hope that helps!
:)
 

Attachments

  • MultipleListboxCriteria.zip
    24.3 KB · Views: 605

MiikkaT

New member
Local time
Today, 08:53
Joined
Dec 23, 2007
Messages
4
Thanks guys! Now I must try out what you have suggested.
 

Users who are viewing this thread

Top Bottom