CodeMed
CodeMed

Reputation: 9189

check for null value in MS Access SQL statement

The following query is not returning values for CurrentVisitor in my ms access 2010 database:

SELECT h.ClientNumber, IIf(h.CheckoutDate=null,"Yes","") AS CurrentVisitor 
FROM VisitsTable AS h 
INNER JOIN (
    SELECT ClientNumber, MAX(LastVisitDate) AS LastVisitStart 
    FROM VisitsTable 
    GROUP BY ClientNumber)  
    AS t 
ON (h.LastVisitStart = t.LastVisitStart) AND (h.ClientNumber = t.ClientNumber);

I think the reason is that the check for null in the If() operation is not written correctly. Can anyone show me how to fix this?

Upvotes: 11

Views: 55538

Answers (1)

Chris Rolliston
Chris Rolliston

Reputation: 4808

Use

Is Null

rather than

= Null

Upvotes: 28

Related Questions