# How would you interpret an IMMEDIATE IF statement in Access 2003?

How would you interpret an IMMEDIATE IF statement in Access 2003 as follows?

IIf([SL]="S",IIf([Direction]="Credit","A","B"),IIf(Direction="Credit","D","C")) AS T
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
This is how to build the nested IIF.

IIF( logic1, a, b)
b= IIF(logic2, c, d)
d=IIF(logic3, e, f)

IIF( logic1, a, b)
if logic evaluates to false,

replace for b gives:
IIF( logic1, a, IIF(logic2, c, d))

replace for d gives:
IIF(logic1, a, IIF(logic2, c, IIF(logic3, e, f))

logic1,  is an expression that evaluates to false or true.
Or you can replace for a, and c if logic evaluates to true.
0
Analyst Assistant Commented:
If [SL] equals "S" And [Direction] equals "Credit" return "A".

If [SL] equals "S" And [Direction] does not equal "Credit" return "B".

If [SL] does not equal "S" And [Direction] equals "Credit" return "C".

If [SL] does not equal "S" And [Direction] does not equal "Credit" return "D".
0
Author Commented:
My goal is as follows:

IF S/L = S  And Direction = Credit           Then T should be assigned the value D
= S       And Direction = Debit             Then T should be assigned the value C

IF S/L = L  AND Direction = Debit           Then T should be assigned the value B
= L  AND Direction = Credit          Then T should be assigned the value A
0
Analyst Assistant Commented:
Perhaps Switch would be better for that?

Expr1: Switch(([SL]="S" And [Direction]="Credit"),"D",
([SL]="S" And [Direction]="Debit"),"C",
([SL]="L" And [Direction]="Credit"),"B",
([SL]="L" And [Direction]="Debit"),"A")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
Comment was typed when answer was accepted.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.