How to filter a query using a field from another table in access?

Jarred Meyer
Jarred Meyer used Ask the Experts™
on
I have a table called EmpBasic which lists Employees. I want to run a query on that table that gets any ebEmpID filtered out based on the EmpIDs found in tblFilter.

How can I use the filter table tblFilter to filter out my query on EmpBasic?

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Nerd
Most Valuable Expert 2012
Top Expert 2013
Commented:
Try this:


SELECT * FROM EmpBasic 
WHERE ebEmpID IN (SELECT EMPID FROM tblFilter)

Open in new window

mbizupNerd
Most Valuable Expert 2012
Top Expert 2013

Commented:
Or even this, using an inner join (might be faster)

SELECT EmpBasic .* FROM EmpBasic INNER JOIN tblFilter ON EmpBasic.ebEmpID  = tblFilter.EMPID
Jarred MeyerProduction Manager

Author

Commented:
The tblFilter actually contains a list of the EmpIDs I don't want to appear in the query.. I just changed the first example to NOT IN.

That does the job though!
mbizupNerd
Most Valuable Expert 2012
Top Expert 2013

Commented:
<< to filter out my query on EmpBasic? >>

I was reading that backwards.  Sorry about that.

Glad you worked it out.
Jarred MeyerProduction Manager

Author

Commented:
No problem.. It got the job done!

Thanks for the prompt help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial