• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Do you know how to write a SQL statement using Access 2003 with an MDB type file that uses a multiple IF statement?

I am developing an Access application using Access 2003 with an MDB type file.

Do you know how to write a SELECT statement to perform the following:

If field S/L has a value of S  and  field DR/CR has a value of Credit,  then field T =  A  ELSE
If field S/L has a value of S  and  field DR/CR has a value of Debit,   then field T = B   ELSE
If field S/L has a value of L  and  field DR/CR has a value of Debit,   then field T =  C  ELSE
If field S/L has a value of L  and  field DR/CR has a value of Credit   then field T = D

0
zimmer9
Asked:
zimmer9
1 Solution
 
CurtHugoCommented:
Use nested IIF statements to get the desired results:

SELECT SL, DRCR, IIf([SL]="S",IIf([DRCR]="Credit","A","B"),IIf([DRCR]="Credit","D","C")) AS Result
FROM MyTable
ORDER BY SL, DRCR;

This will work only if SL equals S or L and DRCR only equals Credit or Debit. If this is not true let me know and we'll go from there.
0

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now