multiple key word searches

raymond3090

Registered User.
Local time
Today, 18:07
Joined
Sep 5, 2002
Messages
43
Hi again,

nobody has been responding to my previous post, so I'll try and refine my question a little.

Right now I have a query, searchResults, which displays seven fields from one of my tables. I have the criteria section of the first field set as follows:

Like "*" & [Forms]![Search]![textTitle] & "*"

which correspongs to a text box on my main Search form.

What I want to achieve on my main search form is a set of seven text boxes, one corresponding to each field in my query set. I would like to fill in any known pieces of information into any (or all) of these text boxes, hit the search button and have a resulting, very refined, set of records which match the keywords.

If there is an easier way of doing this, please inform me!

Right now I have only been able to do this with one keyword. Any help would be very much appreciated.

Regards,

Raymond Warren
 
Last edited:
You are going to have to build your WHERE clause dynamically as the user may not use all 7 criteria keys, I assume.
I'm guessing you are using Combo Box controls, so have the Default property set to: "Make Selection"

WHERE_STR = ""
If CmbCrit1 <> "Make Selection" Then WHERE_STR = "Field1 = " & CmbCrit1 & " AND "
If CmbCrit2 <> "Make Selection" Then WHERE_STR = "Field2 = " & CmbCrit2 & " AND "
:
:
If CmbCrit7 <> "Make Selection" Then WHERE_STR = "Field7 = " & CmbCrit7 & " AND "

'Remove trailing AND

WHERE_STR = Left(WHERE_STR, (Len(WHERE_STR) - 4))

Concatonate this to your SELECT statement if opening a recordset or place this in the WHERE section if opening a report.

HTH
 

Users who are viewing this thread

Back
Top Bottom