MS Access Query using In Fuction to filter data... or not
Posted on 2013-11-20
I have Table1 and table2. Table1 has all my records and Table2 may or may not have any records in it. Both Tables have a Field named EmployeeID. I would like to write a query that will show all the record from table1 IF table2 has no records in it (Null) or if table2 has any record in it, then show record from table1 where the employee_ID match in both tables (The relationships is a one (table2)-to-many(Table1) . Can it be done in a query? How? I was thinking of using the IN FUNCTION but that does not give me any data when table2 is null.
WHERE (((qrySearch.Employee_ID) In (SELECT Table2. Employee_ID FROM Table2)));