?
Solved

Access - Excluding records from one table based on another table

Posted on 2015-01-26
2
Medium Priority
?
1,089 Views
Last Modified: 2015-01-26
In a query with two tables, is there a way to pull records from one table based on excluding records from the second table?  For example, I have one table with medical claims and a second with a list of hospital ID's for one group of hospitals.  I want to pull all of the claims that DIDN'T go to any of the hospitals listed in the second table.  Also, I'd like to do this without using SQL statements.

Any help would be appreciated!

T_Van
0
Comment
Question by:T_Van
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 40571083
I'm not sure what you mean by "without using SQL statements" ... that's really the only way to exclude them, unless you're going to loop through the entire recordset and ignore those that don't have an associated Hospital record.

You can do a LEFT JOIN, and then filter for any that have NULL values:

SELECT * FROM Table1 LEFT JOIN Table2 ON Table1.HospitalID=Table2.HospitalID WHERE Table2.HospitalID IS NULL

If there is no corresponding HospitalID in Table2, that column would be NULL ...

Obviously, you'd have to change the Table and Field names to match your own structure.
0
 

Author Comment

by:T_Van
ID: 40571145
Scott,

By following your SQL statement, I was able to figure out what you did.  In a simple Access query, it's just a matter of adding the hospital ID from the second table as part of the criteria, and putting "IS Null" for the criteria for that field.

It worked perfectly.  Thanks for the help!

T_Van
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question