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
619 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 36

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

679 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