Originally posted by mforema
The code worked on my database because I am searching the equivalent of the text of the Article rather than a table of keywords. My text is only a few lines long for each record. Your situation is obviously much larger.
Anyway, I have worked out a method that should help you.
It requires a second Public Function to count the number of keywords to search for and combines that with the number of keywords found (using the ANY search, not the ALL search). So, if there are 2 keywords to find, but the article only contains 1 of them, that article is discarded.
Originally posted by FishVal (previously #8)
Dim intPos As Integer
CountKeywords = 0
If IsNull(strKeyWo rds) Then Exit Function
Do
intPos = InStr(1, strKeyWords, ",")
If intPos = 0 Then
CountKeywords = CountKeywords + 1
Else
strKeyWords = Trim(Mid(strKey Words, intPos + 1))
CountKeywords = CountKeywords + 1
End If
Loop Until intPos = 0
End Function[/CODE]
Your SQL then becomes something like[CODE=sql]SELECT [your_fields]
FROM
(tblLitCategori es INNER JOIN tblLiteratureAr ticles ON
tblLitCategorie s.Abbreviation = tblLiteratureAr ticles.Abbrevia tion)
INNER JOIN tblArticleKeywo rd ON
tblLiteratureAr ticles.ArticleI D = tblArticleKeywo rd.[Article ID]
WHERE
KeyWordsInStr([Forms]![Form1]![txtKeywords], tblArticleKeywo rd.Keyword)=Tru e
AND tblLitCategorie s.Selected=True
GROUP BY [your_fields]
HAVING (((Count(tblArt icleKeyword.[Article ID])) = CountKeywords([Forms]![Form1]![txtKeywords])));[/CODE]
Substitute [your_fields] with a list of the fields you want to see, make sure you duplicate that list in the GROUP BY clause, otherwise you will see error messages about fields not being included as part of an aggregate function.
Hopefully you should be really close now.
Comment