Results 1 to 7 of 7
  1. #1
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176

    Question Search Question - Multiple boxes, multiple fields

    I have a table that has 4 fields with words in them.
    I want to be able to enter key words to search through all of the fields.
    I have 3 text boxes to enter search key words.

    This is what I came up with
    Code:
    WHERE 
    (((LessonInformation.LongDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW1] & "*" And (LessonInformation.LongDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW2] & "*" And (LessonInformation.LongDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW3] & "*")) 
    
    OR (((LessonInformation.ShortDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW1] & "*" And (LessonInformation.ShortDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW2] & "*" And (LessonInformation.ShortDescription) Like "*" & [forms]![Home]![SearchByWord]![SKW3] & "*")) 
    
    OR (((MasterSpec.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW1] & "*" And (MasterSpec.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW2] & "*" And (MasterSpec.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW3] & "*")) 
    
    OR (((MasterSpec_1.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW1] & "*" And (MasterSpec_1.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW2] & "*" And (MasterSpec_1.Description) Like "*" & [forms]![Home]![SearchByWord]![SKW3] & "*"));
    But this makes it so that the key words have to be in the same field...
    Ex: field1: metal railing, field2: masonry
    If I search for metal and masonry I will get no results
    If I search for metal and railing I will get results



    I think this is simple but I'm having a hard time coming up with an alternative.

    Thanks!
    Last edited by offie; 02-26-2014 at 02:35 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You mean you have a query that has 4 fields with words in them? That WHERE shows 3 tables as source, not a single table. It looks like MasterSpec is included in the source query twice - why?

    Do LessonInformation and MasterSpec have a relationship?

    Do any records ever have null in any of the fields?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I worked with a poster "meep" who was looking for something similar.
    The discussion is at
    https://www.accessforums.net/queries...09/index4.html and is fairly long. If you follow the posts you will see the questions and answers that lead to the database with the search.

    The sample database - I'm not sure how experienced you are - is in post#50 at
    https://www.accessforums.net/queries...index4.html#50

  4. #4
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    I decided to just add all the text strings into one field, make it not visible, and then search through that.


    Field: [LessonInformation].[LongDescription] & [LessonInformation].[ShortDescription] & [MasterSpec].[Description] & [MasterSpec_1].[Description]

    criteria: like "*" & [forms]![Home]![SearchByWord]![SKW1] & "*" And Like "*" & [forms]![Home]![SearchByWord]![SKW2] & "*" And Like "*" & [forms]![Home]![SearchByWord]![SKW3] & "*"

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Terrific idea but you might want to concatenate a space between each. Also, Field is a reserved word so use something like FieldsComb.

    [LongDescription] & " " & [ShortDescription] & " " & [MasterSpec].[Description] & " " & [MasterSpec_1].[Description]
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    Thanks, forgot to do that, and since it's not visible it doesn't need a name I was just specifying that it was in the field row.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Glad you have a solution

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-05-2013, 09:47 AM
  2. Search records based on multiple check boxes
    By maytricks in forum Access
    Replies: 4
    Last Post: 01-14-2013, 07:26 PM
  3. Multiple Search Boxes
    By Hamm in forum Queries
    Replies: 6
    Last Post: 12-03-2012, 11:01 AM
  4. Search across multiple fields
    By Nexus13 in forum Programming
    Replies: 2
    Last Post: 07-08-2011, 02:38 PM
  5. Replies: 4
    Last Post: 09-22-2010, 01:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums