T
Tara
I'm trying to create a query that requires a lengthy nested IIIf statement.
So lengthy in fact that I'll have to split the nested statement into 2 fields
and then combine them later on. I know there is a way to do this with code
(and I know that doing it with code is the best way), but I have no idea
where to start. Here's the SQL for the query currently - I didn't post the
entire nested IIf statement in order to save space:
SELECT tblClients.ClientID, ([ClientFirst] & " " & [ClientLast]) AS Name,
tblClients.StreetAddress, tblClients.City, tblClients.State, tblClients.Zip,
tblClients.[EDC/DOB], DateDiff("d",[EDC/DOB],Date()) AS CurrentAge,
IIf([CurrentAge]<-30,"TGY Becoming A Parent",IIf([CurrentAge] Between -30 And
-15,"TGY Getting Ready",IIf([CurrentAge] Between -14 And 15,"TGY
Newborn",IIf([CurrentAge] Between 15 And 45,"TGY Months 1 &
2",IIf([CurrentAge] Between 46 And 75,"TGY Months 2 & 3",IIf([CurrentAge]
Between 76 And 105,"TGY Months 3 & 4",IIf([CurrentAge] Between 106 And
135,"TGY Months 4 & 5"))))))) AS Packet
FROM tblClients;
So lengthy in fact that I'll have to split the nested statement into 2 fields
and then combine them later on. I know there is a way to do this with code
(and I know that doing it with code is the best way), but I have no idea
where to start. Here's the SQL for the query currently - I didn't post the
entire nested IIf statement in order to save space:
SELECT tblClients.ClientID, ([ClientFirst] & " " & [ClientLast]) AS Name,
tblClients.StreetAddress, tblClients.City, tblClients.State, tblClients.Zip,
tblClients.[EDC/DOB], DateDiff("d",[EDC/DOB],Date()) AS CurrentAge,
IIf([CurrentAge]<-30,"TGY Becoming A Parent",IIf([CurrentAge] Between -30 And
-15,"TGY Getting Ready",IIf([CurrentAge] Between -14 And 15,"TGY
Newborn",IIf([CurrentAge] Between 15 And 45,"TGY Months 1 &
2",IIf([CurrentAge] Between 46 And 75,"TGY Months 2 & 3",IIf([CurrentAge]
Between 76 And 105,"TGY Months 3 & 4",IIf([CurrentAge] Between 106 And
135,"TGY Months 4 & 5"))))))) AS Packet
FROM tblClients;