Results 1 to 12 of 12
  1. #1
    Huddle is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2010
    Posts
    318

    Trying to format a percentage

    For some reason, I have been unable to format a number to a percentage in either the form or query properties. I found this format formula on another site, however I only want 0 decimals i.e. 50% not 50.00%



    Is there a way to use the formula and get 0 decimals??

    PctWTMD: Format(IIf([WTMD_Totals]=0,"-",[WTMD_PMI_Complete]/[WTMD_Totals]),"Percent")

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    You posted in forms forum, but what you posted looks like a query calculated field so I'm answering based on that.
    Can't see any sample values, but how about replacing "Percent" with a single zero?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    You can concatenate the % character.

    Format function results in a text string, not a number. If you need to do further calculations with this value, do not use Format() function.
    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.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Or wrap Format in Cint or Clng etc.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    Or use Round() even?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Wrapping Format using "Percent" with CInt or CLng fails with type mismatch. Could use Val().
    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.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Well, I did say to use 0 and not Percent?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    And then data is not presented as a percentage. I avoid formatting in queries. Apply format in textbox properties.

    I've never used the Percent Format setting in table but maybe that would work for OP.
    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.

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    I would forget about trying to format in your query - the format function will convert it to a string and the format property won't carry forward to the form, just use the format property of the form control - put

    0%;-0%;-

    and set decimals to 0

    change your formula in your query to

    PctWTMD: [WTMD_PMI_Complete]/[WTMD_Totals]

    or just include the calculation as the controlsource to your form

  10. #10
    Huddle is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2010
    Posts
    318
    Quote Originally Posted by CJ_London View Post
    I would forget about trying to format in your query - the format function will convert it to a string and the format property won't carry forward to the form, just use the format property of the form control - put

    0%;-0%;-

    and set decimals to 0

    change your formula in your query to

    PctWTMD: [WTMD_PMI_Complete]/[WTMD_Totals]

    or just include the calculation as the controlsource to your form


    This is how I normally do it, but my format is grayed out. Do you know what could be causing that problem?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    What do you mean by 'format is grayed out' - grayed out where? Certainly not on the Property Sheet?
    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.

  12. #12
    Huddle is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2010
    Posts
    318
    I figured it out. I just had to multiply by 1 in an underlying query. Seems to be working now. Thanks.

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

Similar Threads

  1. Format expession as percentage
    By streub in forum Access
    Replies: 2
    Last Post: 01-09-2018, 10:45 AM
  2. Field format Percentage
    By Gopans in forum Access
    Replies: 4
    Last Post: 05-16-2017, 01:05 AM
  3. Replies: 2
    Last Post: 02-11-2013, 01:26 PM
  4. how to format percentage in access report
    By mdnikki in forum Reports
    Replies: 2
    Last Post: 02-11-2013, 01:20 PM
  5. Problem with percentage format
    By APD in forum Access
    Replies: 2
    Last Post: 08-30-2011, 09:07 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