Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How would you write the following Access query statement in pseudocode - IIf([SL]="L",IIf([Direction]="Credit","D","C"),IIf(Direction="Credit","A","B")) AS T ?

How would you read this full statement in pseudocode from an Access application?

 IIf([SL]="L",IIf([Direction]="Credit","D","C"),IIf(Direction="Credit","A","B")) AS T
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Spot on except:


Check the value of [SL].

If it the value of [SL] equals "L", then check the value of [Direction]. If the value of [Direction] equals "Credit" then return "D".
 If  it does not equal "Credit" then return a

"C"


If the value of [SL] does not equal "L", then check the value of [Direction]. If the value of [Direction] equals "Credit" then return "A". If it does not equal "Credit" then return "B"
Scott really should have gotten that credit, I simply pointed out a typo.
Avatar of zimmer9

ASKER

How would I modify my answer.
Your statement should be:
 IIf([SL]="L",IIf([Direction]="Credit","D","C"),"B")) AS T


IF SL = "L"
      IF Direction = "Credit"
            "D"
      ELSE
            "C"
      END IF
ELSE
      "B"
END IF
@hnasr,
Your suggestion omits one of the options.
There are two conditions, each with two outcomes so you should have four possible results.  Your recast expression has only three.

IF SL = "L"
      IF Direction = "Credit"
            "D"
      ELSE
            "C"
      END IF
ELSE 
      IF Direction = "Credit"
            "A"
      ELSE
            "B"
      END IF
END IF 

Open in new window