Results 1 to 5 of 5
  1. #1
    badmem is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2016
    Posts
    24

    How does the IIF function display decimal places?

    I have a query that uses a calculated field DISPDDE: IIf([DDEROUND]<0.1,"M",[DDEROUND])



    The DDEROUND is a calculated field. It displays the result to one decimal place - 0.4, 1.0, 1.4 etc. The IIF result shows 0.4 and 1.4 correctly, but 1.0 shows as 1, not 1.0.

    Is there any way to display this correctly?

    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you can format DDEROUND to show any # of decimals you want.
    The IIF doesnt handle formatting, it reads the real number.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you have another issue - if DDEROUND is < 0.1 then it returns a number, otherwise it returns text. Mixing datatypes in this way is looking for trouble.

    suggest

    DISPDDE: IIf([DDEROUND]<0.1,"M",format([DDEROUND],"0.0"))

    which will convert your number to text to display 1dp

  4. #4
    badmem is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2016
    Posts
    24
    Thank you for your very fast replies. The result of the IIf will only be used to print a report - it won't be used for any calculations. I hope that will avoid problems with the mix of numbers and text. We don't want "0" to show on the reports, so <0.1 is shown as "M" - below reporting level.

    The DDEROUND calculation is formatted to FIXED 1 decimal place and shows the correct result 1.0. I was surprised that IIf misses off the ".0" but displays other decimal points correctly. I'll try putting the format statement in the calculation as suggested.

    Thanks again.

  5. #5
    badmem is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2016
    Posts
    24
    Putting the Format command into the query worked - the numbers are showing as 1.0 now.

    Thanks again

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

Similar Threads

  1. Formatting for 3 decimal places
    By Triland in forum Forms
    Replies: 12
    Last Post: 01-24-2013, 10:49 AM
  2. Decimal Places
    By momodoujimnjie in forum Access
    Replies: 1
    Last Post: 01-09-2013, 04:49 AM
  3. Report decimal places
    By jackyoung2012 in forum Reports
    Replies: 1
    Last Post: 03-22-2012, 12:12 PM
  4. Limiting decimal places
    By Cran29 in forum Access
    Replies: 13
    Last Post: 01-08-2011, 08:01 AM
  5. Changing decimal places
    By stupesek in forum Reports
    Replies: 12
    Last Post: 09-01-2010, 11:33 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