Results 1 to 7 of 7
  1. #1
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    12

    exclude some records from query


    Hi.
    I have a table called "tblParts". Some records from this table are as follows.
    Id Name Level IdSuperior
    04 Bad 0 Null
    17 Wardrobe 0 Null
    15 Shelf 3 10
    19 Side Board 1 22
    20 Bottom 2 12
    19 Side Board 0 Null

    Point: Id 19 is correctly entered twice.
    Question: How to "make" query where ALL id's where level is 0 and id superior is Null are NOT in the result of query? It means all entries of product Id 19 should be excluded from query result if one of entries has level 0 AND idSuperior Null.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Open the query editor in design mode and add the field and criteria required.
    You will use a Select query.

    https://www.youtube.com/results?sear...s+select+query
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    12
    Sorry,
    if write criteria LEVEL = 0 and IdSuperior = Null I wil stil get product with Id = 19 and LEVEL = 1 and IdSuperior = 22.
    That would be easy.
    But I want ALL id =19 to be excluded if one of them has LEVEL = 0 and IdSuperior = Null.
    See the difference?

  4. #4
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    12
    Sorry,
    if write criteria LEVEL = 0 and IdSuperior = Null I wil stil get product with Id = 19 and LEVEL = 1 and IdSuperior = 22.
    That would be easy.
    But I want ALL id =19 to be excluded if one of them has LEVEL = 0 and IdSuperior = Null.
    See the difference?

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    430
    maybe something like:
    Code:
    SELECT tblParts.* FROM tblParts WHERE ID NOT IN (SELECT tblParts.ID
    FROM tblParts WHERE 
    (DCOUNT("1","TBLPARTS","ID=" & [ID] & " AND ISNULL(IDSUPERIOR)=TRUE")>0 AND  
    DCOUNT("1","TBLPARTS","ID=" & [ID] & " AND ISNULL(IDSUPERIOR)=FALSE")>0))

  6. #6
    MishaLjusha is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Posts
    12
    thx.
    I will try first thing I come home😉

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Exclude Some Values From Query
    By hangbill in forum Queries
    Replies: 7
    Last Post: 12-27-2019, 06:22 PM
  2. Exclude when the current month is the month to exclude?
    By aellistechsupport in forum Queries
    Replies: 15
    Last Post: 05-16-2015, 09:49 PM
  3. Replies: 10
    Last Post: 07-04-2014, 12:29 AM
  4. Replies: 7
    Last Post: 03-03-2014, 03:33 AM
  5. Replies: 2
    Last Post: 10-08-2011, 06:33 PM

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