Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

... FormatPercent Function ...

Discussion in 'Information Technology' started by Dr. Darrell, Jul 28, 2006.

  1. Dr. Darrell

    Dr. Darrell
    Expand Collapse
    Guest

    I have looked up FormatPercent Function and received the following
    instructions.

    **********************************************************
    FormatPercent Function

    Description

    Returns an expression formatted as a percentage (multipled by 100) with a
    trailing % character.

    Syntax

    FormatPercent(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit
    [,UseParensForNegativeNumbers [,GroupDigits]]]])

    The FormatPercent function syntax has these parts:

    Part Description
    Expression Required. Expression to be formatted.
    NumDigitsAfterDecimal Optional. Numeric value indicating how many places to
    the right of the decimal are displayed. Default value is –1, which indicates
    that the computer's regional settings are used.
    IncludeLeadingDigit Optional. Tristate constant that indicates whether or
    not a leading zero is displayed for fractional values. See Settings section
    for values.
    UseParensForNegativeNumbers Optional. Tristate constant that indicates
    whether or not to place negative values within parentheses. See Settings
    section for values.
    GroupDigits Optional. Tristate constant that indicates whether or not
    numbers are grouped using the group delimiter specified in the computer's
    regional settings. See Settings section for values.


    Settings

    The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits
    arguments have the following settings:

    Constant Value Description
    vbTrue –1 True
    vbFalse 0 False
    vbUseDefault –2 Use the setting from the computer's regional settings.


    Remarks

    When one or more optional arguments are omitted, the values for omitted
    arguments are provided by the computer's regional settings.

    Note All settings information comes from the Regional Settings Number tab.
    ***********************************************************
    I want to type 50 into my form or table and I want to display 50% (I also
    want the value to be .50)

    What should I type in for the Expession?

    Darrell
     
  2. Loading...


  3. Steve Schapel

    Steve Schapel
    Expand Collapse
    Guest

    Darrell,

    Formatting has an effect on the way that data is displayed, but it does
    not affect the actual value of the data.

    If you want to type in 50, and have the value recorded as 0.5, then you
    are changing the actual value of the data, so this is not format-related.

    This is easy to achieve. For example, on the After Update event of the
    textbox in question, you can write a procedure like this...

    Me.NameOfTextbox = Me.NameOfTextbox / 100

    In practice, however, this can present difficulties. For example, you
    can't really edit an existing value without re-entering.

    In my opinion, it is less problematic to do one of these approaches:

    1. Enter the actual value you want. That means either enter .5 or 50%.
    You can use the Format property of the textbox to cause it to display
    as percentage, so if you type in .5 it will immediately show as 50%.

    2. Enter 50 and leave it as 50. On your form you can put a label to
    the right of the textbox to show '%'. And then, you need to remember to
    divide by 100 whenever you use the value from this field in your queries
    or reports.

    --
    Steve Schapel, Microsoft Access MVP

    Dr. Darrell wrote:
    > I have looked up FormatPercent Function and received the following
    > instructions.
    >
    > **********************************************************
    > FormatPercent Function
    >
    > Description
    >
    > Returns an expression formatted as a percentage (multipled by 100) with a
    > trailing % character.
    >
    > Syntax
    >
    > FormatPercent(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit
    > [,UseParensForNegativeNumbers [,GroupDigits]]]])
    >
    > The FormatPercent function syntax has these parts:
    >
    > Part Description
    > Expression Required. Expression to be formatted.
    > NumDigitsAfterDecimal Optional. Numeric value indicating how many places to
    > the right of the decimal are displayed. Default value is –1, which indicates
    > that the computer's regional settings are used.
    > IncludeLeadingDigit Optional. Tristate constant that indicates whether or
    > not a leading zero is displayed for fractional values. See Settings section
    > for values.
    > UseParensForNegativeNumbers Optional. Tristate constant that indicates
    > whether or not to place negative values within parentheses. See Settings
    > section for values.
    > GroupDigits Optional. Tristate constant that indicates whether or not
    > numbers are grouped using the group delimiter specified in the computer's
    > regional settings. See Settings section for values.
    >
    >
    > Settings
    >
    > The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits
    > arguments have the following settings:
    >
    > Constant Value Description
    > vbTrue –1 True
    > vbFalse 0 False
    > vbUseDefault –2 Use the setting from the computer's regional settings.
    >
    >
    > Remarks
    >
    > When one or more optional arguments are omitted, the values for omitted
    > arguments are provided by the computer's regional settings.
    >
    > Note All settings information comes from the Regional Settings Number tab.
    > ***********************************************************
    > I want to type 50 into my form or table and I want to display 50% (I also
    > want the value to be .50)
    >
    > What should I type in for the Expession?
    >
    > Darrell
     

Share This Page