ACC: How to Format a Number with a Trailing Percent SignID: Q119482
|
Moderate: Requires basic macro, coding, and interoperability skills.
You cannot use a percent sign (%) in a format statement in Microsoft
Access. Microsoft Access does not recognize the backslash character (\)
(the normal switch to indicate a literal character in a format
string) when used in conjunction with the percent sign. If you do use it,
Microsoft Access will multiply the value by 100. For example, a bound
numeric control with the Format property set to "0%" would return "1200%"
if you entered "12" in the control.
This article describes how to work around this behavior.
One method of working around this behavior is to create a custom function
to return the formatted number. The following example demonstrates this
method:
Option Explicit
Function FormatNumber(Num)
FormatNumber = Format(Num, "0.00") & " %"
End Function
= FormatNumber([Field1])
Keywords : kbusage GnlFrmt
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 6, 1999