saledo2000
Registered User.
- Local time
- Today, 06:26
- Joined
- Jan 21, 2013
- Messages
- 94
Hi everyone,
I am trying to write a query in Access 2013 to get Age for children from Zero to Seventeen years old, but getting an error "Expression too complex in query expression 'Switch'".
SELECT
Rt.*,
Switch(
Rt.Age = 0, [Zero],
Rt.Age = 1, [One],
Rt.Age = 2, [Two],
Rt.Age = 3, [Three],
Rt.Age = 4, [Four],
Rt.Age = 5, [Five],
Rt.Age = 6, [Six],
Rt.Age = 7, [Seven],
Rt.Age = 8, [Eight],
Rt.Age = 9, [Nine],
Rt.Age = 10, [Ten],
Rt.Age = 11, [Eleven],
Rt.Age = 12, [Twelve],
Rt.Age = 13, [Thirteen],
Rt.Age = 14, [Fourteen],
Rt.Age = 15, [Fiften],
Rt.Age = 16, [Sixteen],
Rt.Age = 17, [Seventeen],
) AS [Range]
FROM (
SELECT
ID_Number,
DoB,
IIf(
IsDate([DoB]),
Year(Date()) - Year([DoB]) + (Date() < DateSerial(Year(Date()), Month([DoB]), Day([DoB]))),
Null
) AS Age
FROM tblReg
) Rt;
When I move field names for Age (Zero, One ... Seventeen) from query then is OK, but I need these names to create report in Access. Is there any other solution for my problem.
Thanks.
I am trying to write a query in Access 2013 to get Age for children from Zero to Seventeen years old, but getting an error "Expression too complex in query expression 'Switch'".
SELECT
Rt.*,
Switch(
Rt.Age = 0, [Zero],
Rt.Age = 1, [One],
Rt.Age = 2, [Two],
Rt.Age = 3, [Three],
Rt.Age = 4, [Four],
Rt.Age = 5, [Five],
Rt.Age = 6, [Six],
Rt.Age = 7, [Seven],
Rt.Age = 8, [Eight],
Rt.Age = 9, [Nine],
Rt.Age = 10, [Ten],
Rt.Age = 11, [Eleven],
Rt.Age = 12, [Twelve],
Rt.Age = 13, [Thirteen],
Rt.Age = 14, [Fourteen],
Rt.Age = 15, [Fiften],
Rt.Age = 16, [Sixteen],
Rt.Age = 17, [Seventeen],
) AS [Range]
FROM (
SELECT
ID_Number,
DoB,
IIf(
IsDate([DoB]),
Year(Date()) - Year([DoB]) + (Date() < DateSerial(Year(Date()), Month([DoB]), Day([DoB]))),
Null
) AS Age
FROM tblReg
) Rt;
When I move field names for Age (Zero, One ... Seventeen) from query then is OK, but I need these names to create report in Access. Is there any other solution for my problem.
Thanks.