Results 1 to 7 of 7
  1. #1
    Wilkobeczka is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    8

    Unhappy Search form with multiple keywords for one criterion

    Hello!
    I have a problem with creating a search form which would allow me to look for the records by multiple keywords in the criterion. My db stores information about the characters in the book. How can I make my search form recognize that it stores multiple info about one character and every additional information is not the next one?
    Here is how it looks like.


    This is the way I arranged the characteristics with characters:
    Click image for larger version. 

Name:	personality.PNG 
Views:	22 
Size:	12.1 KB 
ID:	27688
    And this is how I've set the query:
    Click image for larger version. 

Name:	qry.PNG 
Views:	22 
Size:	4.7 KB 
ID:	27689
    The results are as follows: when I want to type a fault which is not in the same line with a virtue, but is connected with the same character, the access doesn't recognize it. What is more I cannot look for characters by typing for example two virtues that I would like them to have. I have a proper (I hope) relation between the main table of the character and the table with its personality traits.
    Click image for larger version. 

Name:	relacja.PNG 
Views:	22 
Size:	9.7 KB 
ID:	27690
    Is there any way to solve my problem?
    Last edited by Wilkobeczka; 03-01-2017 at 04:08 PM. Reason: Forum ate my screenshots

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Two thoughts. You have filled in the same row which I believe is an AND so it must find both in one record before listing. Try putting the second like statement on the row below.

    Secondly, have you considered searching for like * & criteria & *




    Sent from my iPhone using Tapatalk

  3. #3
    Wilkobeczka is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    8
    WORKED! Thank you very much! It now shows a character even if the virtue and a fault are not in the same line.

    However, it still doesn't allow to type many characteristics in one field, as I want to find characters which are BOTH kind and have a good-ear. Or I do not know how to type it, but I've tried several different methods and it still didn't work.

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    This may be of use.

    It includes creating two or more search boxes or creating a parameter query

    https://access-programmers.co.uk/for...d.php?t=140861



    Sent from my iPhone using Tapatalk

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    IMO, your problems are caused by the table "TblCharactersWithPersonality". It is designed like a spreadsheet. There are 2 traits in 1 record.

    I would change the table design to:

    TblCharactersWithPersonality
    -----------------------------
    Field Name
    Field type
    Example
    ID_PK Autonumber
    Character_FK Long Link to TblMainCharacter
    Trait Text Kind, Good-ear, ...
    TraitType Text Fault or Virtue
    Characteristic Integer ???

  6. #6
    Wilkobeczka is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    8
    Ssanfu,
    Thanks, now the table looks much better. However, how should I set the criteria for a query? I've tried to set it several times, but the I got only three results:
    No results at all
    All results
    Or characters sorted only by the 1st trait.

  7. #7
    Wilkobeczka is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    8
    I've tried to add all of the criterion, but it seems like it's not going to work. One thing is that when I try to put a criterion like ">30" in "age", access says that it's invalid or too complex. The second problem is that no matter what I type in the criteria it shows me only one character or no characters.
    SELECT Tabela1.Trait, TblMainCharacter.Race, TblMainCharacter.Age, TblMainCharacter.CharactersName, TblMainCharacter.Sex, TblMainCharacter.Job, TblMainCharacter.Loyalty, TblMainCharacter.CityFROM ((TblMainCharacter INNER JOIN TblCharactersWithPersonality ON TblMainCharacter.[Character] = TblCharactersWithPersonality.[Character]) INNER JOIN TblCharactersInChapters ON TblMainCharacter.[Character] = TblCharactersInChapters.[Character]) INNER JOIN Tabela1 ON TblMainCharacter.Character = Tabela1.Pole1WHERE (((Tabela1.Trait) Like "*" & [Formularze]![Formularz1]![Char2] & "*") AND ((TblMainCharacter.Race) Like "*" & [Formularze]![Formularz1]![Race]) AND ((TblMainCharacter.Age) Like "*" & [Formularze]![Formularz1]![Age] & "*") AND ((TblMainCharacter.CharactersName) Like "*" & [Formularze]![Formularz1]![Surname] & "*") AND ((TblMainCharacter.Sex) Like "*" & [Formularze]![Formularz1]![Sex] & "*") AND ((TblMainCharacter.Job) Like "*" & [Formularze]![Formularz1]![Job] & "*") AND ((TblMainCharacter.Loyalty) Like "*" & [Formularze]![Formularz1]![Loyalty] & "*") AND ((TblMainCharacter.City) Like "*" & [Formularze]![Formularz1]![City] & "*"));
    I gave up when it comes to trying to arrange three fields in a search form with one field in a query, but even without it, access doesn't display what it should display. I'm a complete newbie and looking for a solution already took me a few hours, so any help would be a blessing .

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

Similar Threads

  1. Replies: 4
    Last Post: 05-17-2013, 02:38 AM
  2. Adding Field Using Multiple Criterion
    By kkyork in forum Access
    Replies: 1
    Last Post: 06-06-2012, 01:48 PM
  3. how to highlight search keywords in results form?
    By Absolute_Beginner in forum Forms
    Replies: 2
    Last Post: 08-22-2011, 04:52 AM
  4. Replies: 4
    Last Post: 09-22-2010, 01:47 AM
  5. How to Search for keywords in a Query
    By Brian62 in forum Queries
    Replies: 2
    Last Post: 05-24-2010, 11:14 AM

Tags for this Thread

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