Results 1 to 12 of 12
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    IFF Statement Needs Fixing

    TBALANCE: IIf([ToTBAL]>0 And Not Null,"RED","GREEN")

    Please Help Me Fix This

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try: TBALANCE: IIf([ToTBAL]>0 And Not IsNull([ToTbal]),"RED","GREEN")

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    TBALANCE: IIf([ToTBAL]>0 And Not IsNull([ToTbal]),"RED","GREEN")

    This is not working
    If Totbal is null, I am getting the answer GREEN, where as the answer should be null/Empty

  4. #4
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Angry

    Am Still Stuck With this Problem
    Can Someone Help

    TBALANCE: IIf([ToTBAL]>0 And Not IsNull([ToTbal]),"RED","GREEN")

    This is not working
    If Totbal is null, I am getting the answer GREEN, where as the answer should be null/Empty.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Need to explicitly define rules.

    When should the answer be RED?

    When should the answer be GREEN?

    When should the answer be Null?
    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.

  6. #6
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    When Value is Less than 0 - RED
    When Value is More Than 0 - GREEN
    When Value is Equal to 0 - The Answer Should Be Null or BLUE
    Last edited by aamer; 05-23-2014 at 08:18 AM.

  7. #7
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Youwill need to cascade the ifs:

    Code:
    IIf(IsNull([ToTBAL]);Null;IIf([ToTBAL]>0;"GREEN";IIf([ToTBAL]<0;"RED";"Whatever you want if [ToTBAL]=0")))
    Replace the last string with what ever output you want, when [ToTBAL] = 0.

  8. #8
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    I replaced null with "Whatever you want if"


    IIf(IsNull([ToTBAL]);Null;IIf([ToTBAL]>0;"GREEN";IIf([ToTBAL]<0;"RED";"Null [ToTBAL]=0")))

    or

    IIf(IsNull([ToTBAL]);Null;IIf([ToTBAL]>0;"GREEN";IIf([ToTBAL]<0;"RED";""BLUE" [ToTBAL]=0")))

    This is also not working

  9. #9
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Code:
    IIf(IsNull([ToTBAL]);Null;IIf([ToTBAL]>0;"GREEN";IIf([ToTBAL]<0;"RED";"BLUE")))

  10. #10
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    IIf(IsNull([ToTBAL]);Null;IIf([ToTBAL]>0;"GREEN";IIf([ToTBAL]<0;"RED";"BLUE")))

    by using the above I get the following error

    The expression you entered contains invalid syntax.

    You omitted an operand or operator, you entered an invalid character or comma, or you entered text without surrounding in quotation marks.

  11. #11
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    My fault: replace ; by ,

  12. #12
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thx worked like a charm

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

Similar Threads

  1. Help Needed Fixing the Code
    By aamer in forum Access
    Replies: 8
    Last Post: 03-01-2014, 04:55 PM
  2. Fixing dependency...
    By Uniden in forum Forms
    Replies: 1
    Last Post: 10-08-2011, 02:42 AM
  3. Fixing Reference problem
    By Alex Motilal in forum Access
    Replies: 6
    Last Post: 12-30-2010, 02:12 AM
  4. Help Needed Fixing User ID
    By aamer in forum Access
    Replies: 1
    Last Post: 10-29-2010, 07:27 PM
  5. need a little help fixing an SQL error...
    By markjkubicki in forum Queries
    Replies: 3
    Last Post: 08-04-2010, 06:15 AM

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