By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

Adding More Criteria to a Query

P: 72
I have a query that uses a function to search for keywords separated by commas. The function works great! However, I need the query to also filter based on a yes/no field in a different table. My tables are set-up as follows:

tblLiteratureArticles
Abbreviation (FK)
ArticleID (PK)
Title
Author
etc...
tblLitCategories
Abbreviation (PK - one-to-many relationship with tblLiteratureArticles)
MajorCategory
Selected (Yes/No field)
I want a user to be able to not only enter keywords in the textbox, but to also choose a major category or many categories to search by. I want the query to use the function as it already does, but to also use the Yes/No field from tblLitCategories. Can this be done, and if so, what changes do I need to make to the SQL found below?:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblLiteratureArticles.*
  2. FROM tblLiteratureArticles
  3. WHERE (((KeyWordsInStr(Forms!Form1!txtKeywords,tblLiteratureArticles!ArticleID))<>False));
Thanks!
Aug 3 '07 #1
Share this Question
Share on Google+
1 Reply


P: 72
I have a query that uses a function to search for keywords separated by commas. The function works great! However, I need the query to also filter based on a yes/no field in a different table. My tables are set-up as follows:

tblLiteratureArticles
Abbreviation (FK)
ArticleID (PK)
Title
Author
etc...
tblLitCategories
Abbreviation (PK - one-to-many relationship with tblLiteratureArticles)
MajorCategory
Selected (Yes/No field)
I want a user to be able to not only enter keywords in the textbox, but to also choose a major category or many categories to search by. I want the query to use the function as it already does, but to also use the Yes/No field from tblLitCategories. Can this be done, and if so, what changes do I need to make to the SQL found below?:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblLiteratureArticles.*
  2. FROM tblLiteratureArticles
  3. WHERE (((KeyWordsInStr(Forms!Form1!txtKeywords,tblLiteratureArticles!ArticleID))<>False));
Thanks!
I believe I figured it out. The final solution is below; I will continue testing tomorrow to make sure that it indeed works.

Expand|Select|Wrap|Line Numbers
  1. SELECT tblLiteratureArticles.Abbreviation, tblLiteratureArticles.ArticleID, tblLiteratureArticles.PrincipalAuthor, tblLiteratureArticles.TITLE, tblLiteratureArticles.Journal, tblLiteratureArticles.Volume, tblLiteratureArticles.Number, tblLiteratureArticles.PAGES, tblLiteratureArticles.DATE, tblLiteratureArticles.OtherAuthors, tblLiteratureArticles.Link
  2. FROM tblLitCategories INNER JOIN tblLiteratureArticles ON tblLitCategories.Abbreviation=tblLiteratureArticles.Abbreviation
  3. WHERE (((KeyWordsInStr(Forms!Form1!txtKeywords,tblLiteratureArticles!ArticleID))<>False) And ((tblLitCategories.Selected)=True));
Aug 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.