Problem with Field of type Percentage (1 Viewer)

Bee

Registered User.
Local time
Today, 22:58
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
 

boblarson

Smeghead
Local time
Today, 14:58
Joined
Jan 12, 2001
Messages
32,059
The number has to be entered as a decimal - for example to get 9% you have to enter it as .09.
 

Bee

Registered User.
Local time
Today, 22:58
Joined
Aug 1, 2006
Messages
487
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.
 

RV

Registered User.
Local time
Today, 22:58
Joined
Feb 8, 2002
Messages
1,115
Don't use Long Integer as data type.
Use single or double instead.

RV
 

Bee

Registered User.
Local time
Today, 22:58
Joined
Aug 1, 2006
Messages
487
RV said:
Don't use Long Integer as data type.
Use single or double instead.

RV
That sounds right. Thanks.
 

Bee

Registered User.
Local time
Today, 22:58
Joined
Aug 1, 2006
Messages
487
I tried your recommedation; however, it's still the same.

Any help will be very much appreciated.
B
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:58
Joined
Feb 28, 2001
Messages
27,218
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.
 

Bee

Registered User.
Local time
Today, 22:58
Joined
Aug 1, 2006
Messages
487
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?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 22:58
Joined
Sep 12, 2006
Messages
15,660
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
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:58
Joined
Feb 28, 2001
Messages
27,218
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

Top Bottom