Hi All
I have a textbox with Format "Percent". Now If I type in 90 in the textbox and display the message using below code then it displays 0.9 . why not 90% and also how vcan I store 90% in the field in the table?
ThanksCode:msgbox text1
Hi All
I have a textbox with Format "Percent". Now If I type in 90 in the textbox and display the message using below code then it displays 0.9 . why not 90% and also how vcan I store 90% in the field in the table?
ThanksCode:msgbox text1
0.9 is the Numerical representation of 90%, i.e. the way it must appear to be used in mathematical computations.
If you want to enter 90 and have it mean 90%, you'll need to
- Define the Field, in the underlying Table, as a Text Datatype
- Leave the Format Property blank
- Use the code, below, to add the Per Cent sign
Code:Private Sub PerCent_Field_AfterUpdate() Me.PerCent_Field = Me.PerCent_Field & "%" End Sub
If you later need to use the field for math, you'll have to convert it back to a number, using something like this:
Left(Me.PC_Field, InStr(Me.PC_Field, "%") - 1) / 100
Linq ;0)>
You can have it as a number in the tables but you must divide it by 100:
Format(12.34/100,"##.00%") = "12.34%"