Results 1 to 13 of 13
  1. #1
    supracharger is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2012
    Posts
    13

    Syntax problem with IIF statement

    Could anybody tell me why this Syntax doesn't work (In Red is the problem):
    =IIf([3 Price]="$0.00","",[3 Price])

    How would I re-write that so it would work?



    By Default [3 Price] displays $0.00, and I want it to display nothing (Ex. "")

    Thanx for your help,
    A.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There's nothing wrong with the part in red, and you haven't said what the problem is. My guess is you don't want the quotes around the 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    [3 Price] a control or a field name, or both? Is it a numeric field or string field?

  4. #4
    supracharger is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2012
    Posts
    13
    I'm not quite sure what you are saying but [3 Price] is a Field name in a Table (Currency).
    A>

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As Paul said, try: =IIf([3 Price]=0,"",[3 Price])

    FWI: A Currency field is a special type of field and the $ is not stored.

  6. #6
    supracharger is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2012
    Posts
    13
    My mistake I got it.

    =IIf([3 Price]=0,"",[3 Price])

    But now it won't display Currency; it shows (Ex. 130), and I want it to show (Ex. $130.00).

    How do I get it to display Currency?
    A>

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To what do you have the Format property set? Try Currency.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The double quotes is causing the field to be treated as text. You can use the Format function in the else clause, but what I would do is use the format property of the textbox. It can have 4 parts: positive, negative, null and zls.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    And I should have clarified, that would mean taking out this formula and just using the field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    supracharger is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2012
    Posts
    13
    I got it.
    Thanx so much for you help,
    A.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What did you end up using?

  12. #12
    supracharger is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2012
    Posts
    13
    The I used "Format", I just wasn't thinking.
    A.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for sharing.

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

Similar Threads

  1. Statement Syntax Error
    By Alex O in forum Access
    Replies: 8
    Last Post: 06-08-2012, 08:12 AM
  2. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  3. Case Statement Syntax
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 11-16-2010, 07:18 PM
  4. IIf Statement Syntax Error
    By shexe in forum Queries
    Replies: 2
    Last Post: 10-06-2010, 08:35 AM
  5. Select statement syntax?
    By ksmith in forum Programming
    Replies: 3
    Last Post: 06-24-2010, 09:21 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