% without multiplying by 100 , How ???

Doppenberg

Registered User.
Local time
Today, 06:40
Joined
May 25, 2000
Messages
25
Can someone please help me with the following problem.

When i set the format option of a field to "percentage" a value that is entered is automatically multiplied by 100 , for example "5" will become "500,00%" .

I want the value to become "5,00%".
Does anyone know how to set the format yourself without the "multiply by 100"
When I use the "%" sign the value is multiplied by 100, I can't stop it.

Please help.

Tim.
 
you may need a format tag:
example:
format[fieldname],"##,##0")

play around with that by changing where and how many #'s there are to suit your needs it should work and keep it set at percentage.

HTH
Rpb
 
I hope I understand your problem. What you want is when a user enters the number 75, you want the result in the percent formated txtbox to show 75%. If this is the problem try this.

First 75% is actually 0.75, so if you wish the user to enter a whole number you will need to convert their entry. To do this use the After Update event of the entry txtbox.

This example uses a txtbox named txtYourEntry.

Private Sub txtYourEntry_AfterUpdate()
Me.ActiveControl = Me.ActiveControl / 100
End Sub

When the user enters the whole number 75 the After Update event divides the entry by 100 the displays the result (75%).

I hope I understood your problem correctly.

HTH
RDH

[This message has been edited by R. Hicks (edited 06-15-2000).]
 
Thanks for your help RDH, but it still does not work the way it is supposed to work.

The value in my textbox is now divided by 100 (with the after_update event like you said), but Access rounds the value somehow.

When I enter a value from 1 to 50 i becomes 0,00%, and when I enter a value from 51 to 100 it becomes 100,00%. I set the number of decimals to 2, so that should be OK.

How can I set up Access to NOT round the values?

Tim.
 
Try this, this worked for my db.

Set these values in the property of the control:

Set the format: Percent
Set the inputmask to: "0",00"%";;_
Set the Desimal places: 0
Set the Default value: 0

Make sure the format in the table is Percent also and it should work just fine.

Now you can type in the number 15 and it displays 15 %, or you can type in 0,15 and it displays 15 %, or you can type in 15 %, and it will display 15 %.

This way you don't need any code.
 
Thanks everone.

I found the solutions myself. I made a stupid mistake in the table.
The field was set up as "Currency" with FieldSize set to "Long Integer" by default.
This was the reason Access rounded all the values. It just couldn't handle decimals.

I changed the FieldSize to "Single Precision" and used the After_Update code provided by RDH.
Now everything workes fine: 5,5 becomes 5,50%
15 becomes 15%.

Thanks, Tim.
 

Users who are viewing this thread

Back
Top Bottom