Problem with Field of type Percentage

Bee

Registered User.
Local time
Today, 00:39
Joined
Aug 1, 2006
Messages
487
Hi,

I created a field of type number and formatted to display percentages; however, it seems to add two zeros at the end of every percentage I enter. e.g. if I type 9%, it will show 900%.

Am i doing anything wrong here?

Any help will be very much appreciated.
B
 
The number has to be entered as a decimal - for example to get 9% you have to enter it as .09.
 
boblarson said:
The number has to be entered as a decimal - for example to get 9% you have to enter it as .09.
I will try that. Thank you.
 
Don't use Long Integer as data type.
Use single or double instead.

RV
 
RV said:
Don't use Long Integer as data type.
Use single or double instead.

RV
That sounds right. Thanks.
 
I tried your recommedation; however, it's still the same.

Any help will be very much appreciated.
B
 
Bee, you have two possible ways to do this.

If you store the raw percentage already with the right decimal point, display the number as-is and just ADD the decimal via concatenation.

If you store something else that needs computation, do that via an update query or whatever. In that case, take the percentage in the query.

Now, if the percentage is computable from other data already in the record, don't store it in the first place. Just have the query compute it and use the QUERY as the recordsource.
 
The_Doc_Man said:
Bee, you have two possible ways to do this.

If you store the raw percentage already with the right decimal point, display the number as-is and just ADD the decimal via concatenation.

If you store something else that needs computation, do that via an update query or whatever. In that case, take the percentage in the query.

Now, if the percentage is computable from other data already in the record, don't store it in the first place. Just have the query compute it and use the QUERY as the recordsource.
The Doc Man:

I am storing the raw percentage and it's not calculated. I don't quite understand "ADD the decimal via concatenation."

Could you possibly explain it further?
 
existing records will already be stored incorrectly. you are storing the integer value 9 , or the real value 9.00, so as a percentage it displays as 900%.

you need to store a percentage as a real (double) so that 64% stores as 0.64
You need to change the format as follows

field size double
format percent
number of decimals as appropriate

you may also need to consider the input formatting of any text box as if a user enters 9 (say) it will store as 9 ie 900%.

Users can either enter 0.09 for actually key in 9% to get it correct.

hope this makes it clear
 
OK, first things first. A stored percentage in a database has no meaning other than that which you assign it. Inside a database, you just use the number. HOWEVER, when displaying something (via form/report), you have the opportunity to show how you interpret the field.

So use concatenation such as

FORMAT$( pct, "###.##" ) & "%"

where the ampersand is the string concatenation operator. Until you are going to actually display it, the percent sign is just extra baggage.
 

Users who are viewing this thread

Back
Top Bottom