kentwoodjean
Technical User
I have a hard time formatting the IIF statements, as a matter of fact I normally do not use them because of that. I find that I now have a need and could uses a bit of help. It is an Append Query that calculates the count of contracts in inventory for 5 different RespCdes. What I want to have is a 0 instead of a blank when there is a null value. Below is the SQL of the Append Query:
INSERT INTO InventoryRespID ( FromDate, EndingInven, RespID )
SELECT IIf(Weekday(Date())=2,Date()-3,Date()-1) AS FromDate, Count(tblLastUpdated.[Contract #]) AS EndingInven, RespCdeLst.RespID
FROM tblLastUpdated INNER JOIN RespCdeLst ON tblLastUpdated.[Resp Cd] = RespCdeLst.RespCde
GROUP BY IIf(Weekday(Date())=2,Date()-3,Date()-1), RespCdeLst.RespID, tblLastUpdated.[Closed Dt]
HAVING (((tblLastUpdated.[Closed Dt]) Is Null));
INSERT INTO InventoryRespID ( FromDate, EndingInven, RespID )
SELECT IIf(Weekday(Date())=2,Date()-3,Date()-1) AS FromDate, Count(tblLastUpdated.[Contract #]) AS EndingInven, RespCdeLst.RespID
FROM tblLastUpdated INNER JOIN RespCdeLst ON tblLastUpdated.[Resp Cd] = RespCdeLst.RespCde
GROUP BY IIf(Weekday(Date())=2,Date()-3,Date()-1), RespCdeLst.RespID, tblLastUpdated.[Closed Dt]
HAVING (((tblLastUpdated.[Closed Dt]) Is Null));