mini search engine

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I am trying to create a mini search engine. I have three unbound text boxes
on my form. I want to concatenate the words places in each box and run a
query such that if the target field (SubjectLine) contains those three words,
then show it.

Comparitively, I would like to do this using the OR operator aswell.

I have considered using the "IN" operator, but am not having alot of luck.

Any help would be greatly appreciated.

Regards
 
You need two queries, one to do an "And" comparison and one to do an "Or"
comparison. Place an option group on your form so you can select which
comparison you want and set it as the recordsource of your form. You then
need code like this in the AfterUpdate event of the option group:
Select Case Me!NameOfOptionGroup
Case 1
Me.Recordsource = "NameOfAndQuery"
Else
Me.Recordsource = "NameOfOrQuery"
End Select

"And" Query ----
Create a query that includes SubjectLine. Pull down SubjectLine three times
into three fields in the query grid. Put the following expression under the
first SubjectLine:
Like "*" & Forms!NameOfYourForm!NameOfTextBox1 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox1 Is Null)
Put the following expression under the second SubjectLine:
Like "*" & Forms!NameOfYourForm!NameOfTextBox2 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox2 Is Null)
Put the following expression under the third SubjectLine:
Like "*" & Forms!NameOfYourForm!NameOfTextBox3 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox3 Is Null)

"Or" Query ----
Create a query that includes SubjectLine. Pull down SubjectLine three times
into three fields in the query grid. Put the following expression under the
first SubjectLine:
Like "*" & Forms!NameOfYourForm!NameOfTextBox1 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox1 Is Null)
Put the following expression under the second SubjectLine in the SECOND ROW
of criteria:
Like "*" & Forms!NameOfYourForm!NameOfTextBox2 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox2 Is Null)
Put the following expression under the third SubjectLine in the THIRD ROW of
criteria:
Like "*" & Forms!NameOfYourForm!NameOfTextBox3 & "*" Or
(Forms!NameOfYourForm!NameOfTextBox3 Is Null)

Note: It is IMPORTANT that the three criterias be in different rows!!!
 
Back
Top