Solved

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 ?

Posted on 2014-01-15
7
617 Views
Last Modified: 2014-01-15
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
0
Comment
Question by:zimmer9
7 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39782294
What do you mean by "pseudocode"? The item you've posted is "code" so I'm not sure what you need.

If you're looking for something like a "human translation", then:

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 "D"

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"
0
 
LVL 7

Expert Comment

by:Steve
ID: 39782337
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"
0
 
LVL 7

Expert Comment

by:Steve
ID: 39782475
Scott really should have gotten that credit, I simply pointed out a typo.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:zimmer9
ID: 39782550
How would I modify my answer.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39782644
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
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 39782662
@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

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question