Solved

Access - Excluding records from one table based on another table

Posted on 2015-01-26
2
452 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
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now