locked
Form Display Of Percent Values RRS feed

  • Question

  • We want the screen to show a percent with up to 4 decimal places, a value can be i.e.: 5.1234%
    But if the value does not have 4 decimals not to show the ending zeros. 
    If the value is 5.12% - only show 5.12%  not 5.1200%
    If the value is 5.1234% -  show 5.1234%  not 5.12%
    __
    Table field parameters:
    Type Numeric, Field Size = Single, Format=Percent, Decimal Places=4
    _
    Form Format parameters:
    Format Percent, Decimal Places = 4, shows all 4 but when 5.12 shows 5.1200
    Format Percent, Decimal Places = Auto, when 5.1234 show only 5.12

    Is there a way for this to work?
    Thx
    Russ

    Russ Neuman

    Wednesday, June 28, 2017 12:29 PM

Answers

  • For my previous reply, I set the Format property of a text box on a form.

    But I have now also tried it in the Format property of a field in a table:

    Result:


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by RussNeuman Sunday, July 2, 2017 11:57 AM
    Wednesday, June 28, 2017 7:14 PM

All replies

  • As long as there is at least 1 decimal place, you could use the custom format 0.0###%. This will display 1.2345%, 1.234%, 1.23%, 1.2% and 1.0% (i.e. the first decimal is not suppressed)

    Alternatively, you could use 0.####%. This will display 0.98 as 98.%, not as 98.0%, but not as 98% either...


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, June 28, 2017 1:52 PM
  • Hans - did not work, thanks for the try.

    For:
    Format 0.0###%

    with an entry of 11.1
    result was:
    1110.0000%


    Russ


    Russ Neuman

    Wednesday, June 28, 2017 2:59 PM
  • If I enter 11.1, I get 1110.% - see screenshot.

    If I enter 11.1%, I get 11.1% - see screenshot.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, June 28, 2017 4:12 PM
  • Was your formatting done at the table level or on the form object?

    Russ


    Russ Neuman

    Wednesday, June 28, 2017 6:29 PM
  • For my previous reply, I set the Format property of a text box on a form.

    But I have now also tried it in the Format property of a field in a table:

    Result:


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by RussNeuman Sunday, July 2, 2017 11:57 AM
    Wednesday, June 28, 2017 7:14 PM
  • Hans - thank you for your patience.
    Sorry, it took me awhile to get back to this.  It is effort beyond budget, other pressing efforts.

    Using this format does get the desire result. 

    But, with this format the entry is different.

    1) For entering the percentage 1.123%  the entry is ".01123". 
    While before the entry would be "1.123".

    The fix appears to be an Evert After Update:

    Private Sub TextFee_SystematicFee1_Asset_Based_Annual_Amt_AfterUpdate()
    Me.Fee_SystematicFee1_ASSET_Based_Annual_Amt = Me.Fee_SystematicFee1_ASSET_Based_Annual_Amt * 0.01
    End Sub

    Does this sound correct?

    Russ


    Russ Neuman

    Sunday, July 2, 2017 12:12 PM
  • If you set the Format property to Percent with the desired number of Decimal Places, Access will recognize 3 as 3%.

    But if you use a custom format that includes %, such as 0% or 0.00% or 0.####%, you have to type the % sign when you enter data.

    Looks like a bug to me...

    I would hesitate to use the After Update code. It will work correctly when you enter a complete value: 5.43 will be converted to 5.43%

    But if you then edit the value and change 5.43% to 6.43%, the result will be 0.0643%.

    So I'd prefer to omit the After Update code and to type the % sign.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, July 2, 2017 1:58 PM
  • Hans - Thanks for all your help with this request.

    Yes, I rather not do a batch of VBA code for every percentage field. 
    I will request the users do an entry of the percentage sign.

    Russ


    Russ Neuman

    Thursday, July 6, 2017 3:44 PM
  • I will request the users do an entry of the percentage sign.

    Hi Russ,

    Can't you just put the decimal value in the control, and add a (separate) control behind that with the %-character?

    Imb.

    Thursday, July 6, 2017 8:47 PM
  • I do not understand what you mean add a (separate) control?

    What I have now, half working:

    Do you mean an Input Mask?


    Russ Neuman

    Friday, July 7, 2017 8:27 PM
  • Imb-hb means that you format the text box as a number (not as a percentage), and that you place a label with "%" as caption to the right of the text box:


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Friday, July 7, 2017 9:16 PM