Results 1 to 9 of 9
  1. #1
    FriQenstein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    98

    Query search criteria - How to use a "Not = to" search

    Greetings all,



    My DB has quite a few different types of equipment, which I've put all in 1 table per the suggestions of some on this forum which has helped tremendously.

    However, now I'm at a point that I need to build a Query to search for something that does NOT match the other categories.
    For example, I have a Model field which identifies most of the types of equipment that I have in the Table. I also have a Misc category which doesn't fit the normal category of equipment. So, in order for someone to pull up a Report of all the Misc equipment, how would I go about writing up the search criteria string for that?

    My brain is telling me something along the lines of !="blahblah" but that is my programming background and I was having difficulties finding examples of criteria that can be used in the Query.

    Let's say I have the Model category, which Identifies the following: Bird, Gun Type 1, Gun type 2, etc. I was thinking that I could just put in a search string that would say: "whatever is NOT equal to these existing types, show me a list"

    I hope that makes sense.
    The only other idea I had about this was some sort of hidden Identifier that would flag the Misc category. Like a field or something I could tie to the Misc equipment without having to modify too much of the Table.

    The reason for this type of search is that the Misc equipment will not ever fall into the other categories that I already have setup in the Model field. So I cannot add too many extra Model types due to the infrequent amount of times it would be utilized.

    Thanks in advance.
    Regards.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    You can filter for selected items in the Model field using the IN operator e.g. IN ("Bird", "Gun Type 1", "Gun type 2")
    Similarly you can exclude them using NOT IN ("Bird", "Gun Type 1", "Gun type 2") as your filter criteria
    Last edited by isladogs; 03-25-2019 at 04:23 PM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Data structure not clear to me. Are Model and Misc fields? Perhaps show sample table and data.
    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.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    Another interpretation of your question is you want a list of everything from one table which is not in another table eg items v models. If this is the case you would use a left join. Working from my phone right now so difficult to provide some air code perhaps some one else can if this is a valid interpretation

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Along the lines of what Ajax is saying, presuming you have a table of models try the unmatched query wizard comparing the two tables.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    FriQenstein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    98
    Let me see if I can clarify the bit about the Tables.
    I have combined all of the data into 1 Table. So all parts and equipment exist in a Table called Full_Inv.
    I have another Table for Model so I can use this as a reference for each piece of equipment in the main Full_Inv table to classify what type of equipment it is.

    So when a user searches for Gun parts for the G-Gun models, then the query can look for G-Gun criteria. Same for Bolt-Guns.
    In another category I have our Birds which are listed as Model 5011... so any Bird body or part that is used for a Bird is associated with the 5011 Model field.
    Now lets say a user wants to find out how many screws we have for a misc piece of equipment that isn't part of our normal inventory. These screws are still listed in the main Full_Inv table, but they are not associated with a Model (yet).
    So a user wants to find these screws, the query would need to say:
    search for description or part number of this particular type of screw but do NOT show me items matching this particular screw that are part of the following Model...

    Does that make any sense? I hope I've cleared it up a bit.

    I'm going to try isladogs suggestion and see what I can come up with.
    I appreciate all of the help/input.

    Regards.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Since you have a model table, the unmatched query wizard is probably the better option. Colin's method will work, but is not dynamic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    I agree. My answer assumed you only had one table.
    Both methods should work but an unmatched query is more generic.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    FriQenstein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    98
    SOLVED

    Ok. Thanks guys. I've created my Query according to the Model types NOT being present.

    I appreciate the help.

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

Similar Threads

  1. Replies: 2
    Last Post: 01-09-2019, 05:25 AM
  2. Replies: 4
    Last Post: 08-05-2017, 12:33 AM
  3. Replies: 1
    Last Post: 02-03-2015, 11:41 AM
  4. Replies: 5
    Last Post: 12-14-2013, 06:29 AM
  5. Replies: 8
    Last Post: 03-05-2013, 01:20 PM

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