Results 1 to 7 of 7
  1. #1
    djhoneygo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    3

    Excluding records in a query based on info in a table

    I am fairly new to Access, so please forgive me if this question is obvious and/or if it has been answered before.



    I have two tables that I am pulling information out of in a query. One of the tables (Table Errors) includes records that I would like to exclude from the output of the query. The records in that table are a subset of the data in a much bigger table (Table Main Data), and they contain a field indicating that these records are errors. I would like to use the error field to exclude this subset of records from Table Main Data. However, if I link the appropriate fields in Table Errors and Table Main Data, but then add the "Error" field from Table Errors into the query, it shows me the opposite of what I want: only those records which contain the errors. How do I use the "Error" field in Table Errors to exclude these erroneous records from Table Main Data?

    Thanks!

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    In query design view, right-click the line that links the two records. Change the query type to "include all records in the left table that are NOT in hte right table."

  3. #3
    djhoneygo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    3
    Thanks a lot for the response. But I'm not sure this is going to work. When I click on the link, the options are as below (hiatus_results is Table Main Data and Exclusions_test is Table Error):

    Click image for larger version. 

Name:	access_prob.jpg 
Views:	8 
Size:	57.2 KB 
ID:	14729

    If I choose the second option, I'm still not using the Error Table to exclude the records in the Main Data Table that match those records in the Error Table.

    Moreover, when I did try to do this, I got an ambiguous outer join error, even though there's not another table in the query that's also being joined. But it may not be worth it to figure out what that's happening if it's not going to give me the records that I need anyway.

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    I think Dal meant #3. To include "Exclusions_test" (Table Error) and only those records from "hiatus_results" (Table Main Data) where the joined fields are equal.

    What error are you getting? Can you posted the SQL (right click on the "query tab" and select SQL View)?

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    No, neither of those is right. Please use the unmatched query wizard to create your query from scratch.

  6. #6
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    After re-read your original post, I misunderstood your request. You are just misisng "Is Null" as your criteria from the Join column from "Error Table". This is should be the same as using the "Unmatched query".

    For example,
    SELECT MAIN.ID, MAIN.OTHERS, ERROR.ID, ERROR.OTHERS
    FROM MAIN LEFT JOIN ERROR ON (MAIN.ID = ERROR.ID)
    WHERE ERROR.ID Is Null ;

  7. #7
    djhoneygo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    3
    Thanks a lot for the help so far. Trying to figure this out has uncovered some miscoded data that is affecting the query, so I'll need to fix that first to see if I can get this to work for real.

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

Similar Threads

  1. Query is excluding records with blank fields
    By Menelaus in forum Queries
    Replies: 1
    Last Post: 03-28-2013, 08:14 PM
  2. Query for excluding TOP N records
    By dolovenature in forum Queries
    Replies: 1
    Last Post: 09-14-2012, 03:49 PM
  3. Excluding values based on another table
    By hotpants49 in forum Queries
    Replies: 3
    Last Post: 09-08-2012, 11:15 AM
  4. Excluding null values on SQL table query
    By DB2010MN26 in forum Queries
    Replies: 1
    Last Post: 09-03-2010, 12:54 PM
  5. Replies: 4
    Last Post: 02-08-2010, 11:17 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