Full Version: Nested Iif statements
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
kh_9405
To me this looks correct, however it is not working.

The statement is:
IIf([Last Date]="No Elme","No Elme",IIf([Last Date]>=[Pressure_Inspctn Target Date],"Up to Date",[Last Date]))

Here are the SQL details:

SELECT [qryBase_LstDate_Pressr_PerUnit B].Ramp_Code,
[qryBase_LstDate_Pressr_PerUnit B].[Lift_Unit#],
IIf([Last Date]="No Elme","No Elme",IIf([Last Date]>=[Pressure_Inspctn Target Date],"Up to Date",[Last Date]))
AS Pressure_Insp_Date FROM [qryBase_LstDate_Pressr_PerUnit B] INNER JOIN qryBase_Prs_TrgtDate
ON [qryBase_LstDate_Pressr_PerUnit B].Ramp_Code = qryBase_Prs_TrgtDate.Ramp_Code
GROUP BY [qryBase_LstDate_Pressr_PerUnit B].Ramp_Code, [qryBase_LstDate_Pressr_PerUnit B].[Lift_Unit#], IIf([Last Date]="No Elme","No Elme",IIf([Last Date]>=[Pressure_Inspctn Target Date],"Up to Date",[Last Date]));

My problem is that instead of bringing back "Up to Date", it just gives me the last date. Originally I did not have the first Iif statement in there, thinking that since the query with [Last Date] was written to bring back either the max date or "No Elme", that "No Elme" would come back as [Last Date], but it didn't.

Any ideas or thoughts?

Thanks,

Kathy
Jerry Dennison
If [Last Date] is a date field then it will never = "No Elme" which is text.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.