tables format percentages

S

shank

I'm trying to setup one field in my table to show percentages. I've selected
format=percentage and tried everything from deciaml to double to long
integer etc. When I enter the digits "75" the field will display 7500.00%.
How can I setup the field to show 75%? I gotta be missing something simple
here...

thanks
 
S

shank

I understand that, but I guess my thoughts were along entering a value like
"seventy-five percent" as opposed to "seventy-five hundredths of a percent"
to get my desired end results.
thanks
 
D

Duane Hookom

If you want to allow users to enter 75 to represent .75 (75%) then you can
add some code to the After Update event of the text box like:
Private Sub txtPctComplete_AfterUpdate()
If Me.txtPctComplete > 2 Then
Me.txtPctComplete = Me.txtPctComplete / 100
End If
End Sub
If the value entered is greater than 2, the value will be divided by 100.
You might want to check for nulls or change the 2 to 1.
 
T

Tim Ferguson

When I enter the digits "75" the field will display 7500.00%.
How can I setup the field to show 75%? I gotta be missing something
simple here...

An alternative approach is to rethink the design a little bit. A value of
75% _is_ the same as 0.75; and that is how it is stored and typed. What
about storing the PercentagePoints as a number, and then accounting for
that in any maths that comes afterwards:


SELECT FullPrice * (100 - PercentDiscount)/100 AS NetPrice
FROM etc


which is only trivially harder than

SELECT FullPrice * (1 - DiscountFraction) AS NetPrice

which is presumably what you are doing at the moment.

If you want it to look nice, put a label control to the Right of the text
box control and put a single '%' character in it, just to remind users
that they have to put in a percentage amount.

Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top