Results 1 to 5 of 5
  1. #1
    jabadoojr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    6

    How to use multiple IIf statements in a query

    I have a query where I need to use two IIF statements in one field. While they both work seperately, I am having trouble joining them in one statement. Below is the statement I'm working with:





    Expr2: IIf([Gifts with Names]![Type]="Pledge" And [SumOfAmount] Is Null,0,[SumOfAmount], IIf([Gifts with Names]![Type]="Outright Gift",[Gifts with Names]![Gift Amount]))

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    To make sure we don't interpret your formula attempt incorrectly, can you tell to us (in English, not formulaically) exactly how you want the formula to work?

  3. #3
    jabadoojr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    6
    In my table "Gifts with Names" I have two types of gifts; Pledges and Outright Gifts. In my table "SumOfAmount" it totals all pledge payments.

    The first IIf statement (if the gift type is "Pledge") is used to show pledges minus pledge payments, and if there are no payments, it returns zero. The second IIf statement (if the gift type is "Outright Gift") should return the gift amount.

    Again, both of these IIf statments work individually, however we run into problems when we try to combine them. Any help is appreciated!!!

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    I agree with JoeM To give you the proper statement we need to know more about what you need it to do. However, with that said the issue with the statement you posted is the following

    Correct Statement IIF(expression,truepart,falsepart)

    Your statement: IIF(expression,truepart,faslepart,IIF(expression,t ruepart)) Since expression evaluates to 1 of 2 possibilities true/false having a 3rd possibility won't work.

    Looking at what you have I believe what your looking for is as follows:

    IIf([Gifts with Names]![Type]="Outright Gift", [Gifts with Names]![Gift Amount], IIF([Gifts with Names]![Type]="Pledge"And [SumOfAmount] Is Null,0,[SumOfAmount]))

    However that is a guess and nothing more.

  5. #5
    jabadoojr is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    6
    Sorry for the lack of info, but your answer worked! Thanks so much for the help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple iif statements
    By rlsublime in forum Queries
    Replies: 3
    Last Post: 04-25-2012, 10:33 AM
  2. Replies: 1
    Last Post: 09-20-2011, 07:28 PM
  3. Multiple SQL Statements
    By springboardjg in forum Queries
    Replies: 1
    Last Post: 04-18-2011, 10:32 AM
  4. Multiple IIF statements
    By KevinMCB in forum Queries
    Replies: 4
    Last Post: 12-03-2010, 01:35 PM
  5. Replies: 3
    Last Post: 10-13-2010, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums