Solved

Null Values in Access

Posted on 2012-03-21
5
179 Views
Last Modified: 2012-03-22
I have joined two tables(table1 & employeeinfo) and when i enter the code below, i retrieve the desired results, but now i am trying to remove all rows that have a blank value for the employee name since those staff no longer work for the agency.  Employeename is retrieved from the employeeinfo table.  

I thought all i had to do is Where table1.lastuser Is Not Null AND EmployeeName Is NOT Null, but realized that means both those fields have to be Null to be removed.    

SELECT table1.LastUser, [LAST_NAME] & " " & [FIRST_NAME] AS EmployeeName, employeeinfo.REGION, employeeinfo.DEPTNAME, employeeinfo.JOBTITLE
FROM employeeinfo RIGHT JOIN table1 ON employeeinfo.LOGNAME=table1.LastUser
WHERE (((table1.LastUser) Is Not Null));

I have attached what the query looks like now.  The highlighted fields are the only ones i want to retain.
Building.xls
0
Comment
Question by:jsawicki
  • 3
5 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 37750887
Try INNER JOIN
0
 
LVL 30

Accepted Solution

by:
hnasr earned 400 total points
ID: 37750898
SELECT table1.LastUser, [LAST_NAME] & " " & [FIRST_NAME] AS EmployeeName, employeeinfo.REGION, employeeinfo.DEPTNAME, employeeinfo.JOBTITLE
FROM employeeinfo INNER JOIN table1 ON employeeinfo.LOGNAME=table1.LastUser
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 37751296
You can use:

IIf(Trim([LAST_NAME] & " " & [FIRST_NAME]) = "", Null, Trim([LAST_NAME] & " " & [FIRST_NAME])) AS EmployeeName,

Then you filter for EmployeeName Is Null.

/gustav
0
 

Author Closing Comment

by:jsawicki
ID: 37754306
Funny how simple that was, thanks.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 37754626
Welcome!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

821 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