Results 1 to 4 of 4
  1. #1
    cbenisch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    28

    Multiple Iff in same field

    I have a player database for a tournament. I am having an issue with calculating the cost to enter. Here is the calculated field I am using.



    IIf([Player1] Is Null,0,70)+([Player1ExtraDinner]*20)-IIf([Player1Pass]=True,17,0)

    Player1 is a field in the table with a name. If it is blank I want the calculated field to be zero for the fees. If it is not then I need to charge the $70 plus another $20 x the number of Player1ExtraDinner then I need to subtract 17 if the Player1Pass field is true.

    Examples
    Null is $0
    Player1 = bob and no dinners value should be $70
    Player1 = bob and 2 dinners value should be $110
    Player1 = bob and 2 dinners and Player1Pass = true value should be $93

    I have tried many different ways to try and get this to come out right and finally decided to ask for some help.

    Can someone help me with this? Nesting seems to cause me troubles.


    Thanks you in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    IIf([Player1] Is Null, 0, 70 + [Player1ExtraDinner] * 20 - IIf([Player1Pass], 17, 0))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    cbenisch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    28
    Quote Originally Posted by cbenisch View Post
    I have a player database for a tournament. I am having an issue with calculating the cost to enter. Here is the calculated field I am using.

    IIf([Player1] Is Null,0,70)+([Player1ExtraDinner]*20)-IIf([Player1Pass]=True,17,0)

    Player1 is a field in the table with a name. If it is blank I want the calculated field to be zero for the fees. If it is not then I need to charge the $70 plus another $20 x the number of Player1ExtraDinner then I need to subtract 17 if the Player1Pass field is true.

    Examples
    Null is $0
    Player1 = bob and no dinners value should be $70
    Player1 = bob and 2 dinners value should be $110
    Player1 = bob and 2 dinners and Player1Pass = true value should be $93

    I have tried many different ways to try and get this to come out right and finally decided to ask for some help.

    Can someone help me with this? Nesting seems to cause me troubles.


    Thanks you in advance.

    I looked at it again and used


    =((IIf([Player1] Is Null,0,70)+([Player1ExtraDinner]*20))-(IIf([Player1Pass]=True,17,0)))

    Which seems to work as expected.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Glad you have a solution but really don't know why your original expression failed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 8
    Last Post: 06-24-2015, 08:22 AM
  2. Replies: 10
    Last Post: 11-18-2014, 04:25 PM
  3. Replies: 3
    Last Post: 05-06-2013, 03:03 PM
  4. Replies: 8
    Last Post: 04-13-2012, 12:25 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 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