IIf function

G

Guest

The error message I get is that my IIf statement is too complicated. I am
trying to calculate leadtime demand. I want it to find a specific number in
one field and then return a value from another.

LT_Tot_Dmd:
IIf([lead_timeR]=1,[tdmd1],IIf([lead_timeR]=2,[LT2],IIf([lead_timeR]=3,[LT3],IIf([lead_timeR]=4,[LT4],IIf([lead_timeR]=5,[LT5],IIf([lead_timeR]=6,[LT6],IIf([lead_timeR]=7,[LT7],IIf([lead_timeR]=8,[LT8],IIf([lead_timeR]=9,[LT9],IIf([lead_timeR]=10,[LT10],IIf([lead_timeR]=11,[LT11],IIf([lead_timeR]=12,[LT12],IIf([lead_timeR]=13,[LT13],IIf([lead_timeR]=14,[LT14],IIf([lead_timeR]=15,
[LT15] ,IIf([lead_timeR]=16, [LT16] ,IIf([lead_timeR]=17, [LT17]
,IIf[lead_timeR]=18, [LT18] ,IIf([lead_timeR]=19, [LT19]
,IIf([lead_timeR]=20, [LT20] ,IIf([lead_timeR]=21, [LT21]
,IIf([lead_timeR]=22, [LT22] )))))))))))))))))
 
D

Duane Hookom

It looks like you have created a spreadsheet type table rather than a
relational database. If this is the case, I wouldn't spend too much time on
it until it was fixed.

However, it looks like all your values are simple incrementing numbers.
Consider using the Choose() function:
LT_Tot_Dmd: Choose([lead_timeR], [tdmd1], [LT2], [LT3], [LT4], [LT5], [LT6],
[LT7], [LT8], [LT9], [LT10], [LT11], [LT12], [LT13], [LT14],
[LT15], [LT16], [LT17], [LT18], [LT19], [LT20], [LT21], [LT22] )
 
K

Ken Snell [MVP]

Check out the Choose function. It's a perfect fit for this type of
expression. It's in Help file.
 
G

Guest

It worked. Thanks for the help.

Duane Hookom said:
It looks like you have created a spreadsheet type table rather than a
relational database. If this is the case, I wouldn't spend too much time on
it until it was fixed.

However, it looks like all your values are simple incrementing numbers.
Consider using the Choose() function:
LT_Tot_Dmd: Choose([lead_timeR], [tdmd1], [LT2], [LT3], [LT4], [LT5], [LT6],
[LT7], [LT8], [LT9], [LT10], [LT11], [LT12], [LT13], [LT14],
[LT15], [LT16], [LT17], [LT18], [LT19], [LT20], [LT21], [LT22] )

--
Duane Hookom
MS Access MVP


Dogwood said:
The error message I get is that my IIf statement is too complicated. I am
trying to calculate leadtime demand. I want it to find a specific number
in
one field and then return a value from another.

LT_Tot_Dmd:
IIf([lead_timeR]=1,[tdmd1],IIf([lead_timeR]=2,[LT2],IIf([lead_timeR]=3,[LT3],IIf([lead_timeR]=4,[LT4],IIf([lead_timeR]=5,[LT5],IIf([lead_timeR]=6,[LT6],IIf([lead_timeR]=7,[LT7],IIf([lead_timeR]=8,[LT8],IIf([lead_timeR]=9,[LT9],IIf([lead_timeR]=10,[LT10],IIf([lead_timeR]=11,[LT11],IIf([lead_timeR]=12,[LT12],IIf([lead_timeR]=13,[LT13],IIf([lead_timeR]=14,[LT14],IIf([lead_timeR]=15,
[LT15] ,IIf([lead_timeR]=16, [LT16] ,IIf([lead_timeR]=17, [LT17]
,IIf[lead_timeR]=18, [LT18] ,IIf([lead_timeR]=19, [LT19]
,IIf([lead_timeR]=20, [LT20] ,IIf([lead_timeR]=21, [LT21]
,IIf([lead_timeR]=22, [LT22] )))))))))))))))))
 
Top