Format a Percent

W

Wendymel

Hello,

I submitted a question in June (6/24/2009) concerning formatting a percent
field. It was resolved and has worked ever since. Until last week, when we
upgraded to Access 2007.

Here is the original question:
-------------------------------------------------------
"I am trying format a numeric field as percent. My problem is similar to the
posting "Format number field to show percent" by "Kalen" posetd on 1/23/2009.

I have a numeric field named PROJPercComp. I have formatted it as percent
with 0 decimal places.

I want the numbers entered by the user in this field to show as anything
from 1% to 100%. No decimals.

This field is used in a form called frmProjectEntry. It is bound as a source
to a text box called PercCompleted. I used the code suggested by Clifford
Bass in the above mentioned posting. It is:

If Not IsNull(controlname) And Right(controlname, 1) <> "%" Then
controlname = controlname / 100
End If

My version of the After Update code looks like:

If Not IsNull(PercCompleted) And Right(PercCompleted, 1) <> "%" Then
PercCompleted = PercCompleted / 100
End If

What is happening is that if the user enters a number of 50 or less, the
value in the field defaults to 0%. It the user enters a number of 51 to 100
then the value in the field defaults to 100%.

I just want the values to be as entered. No decimals, no rounding. If a
user enters a value of 42 then I want the field to read 42% etc. "

---------------------------------------------------------------------------
And here is the resolution:
---------------------------------------------------------------------------
From the sound of it, your field size (in the table design) is set to Long
Integer, or maybe Integer or Byte. These are whole-number types, and so
can't hold fractional values. Change the field size to Single or Double.
These are floating types, which are suitable for the Percent format.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
--------------------------------------------------------------------------
The problem has returned and I am not sure what to do to correct it.

Please help!.....again.

Wendy
 
D

Duane Hookom

What is the field type?
What happens if you change to
If Nz(PercCompleted,0) > 1 Then
PercCompleted = PercCompleted / 100
End If

Did you change the setting in 2007 to allow running code?
 
W

Wendymel

What setting????

Duane Hookom said:
What is the field type?
What happens if you change to
If Nz(PercCompleted,0) > 1 Then
PercCompleted = PercCompleted / 100
End If

Did you change the setting in 2007 to allow running code?
 
D

Duane Hookom

I believe by default code doesn't run in Access 2007 unless you have allowed
it to run. I have usually seen a notification when I have opened an Access
file in 2007.
 
W

Wendymel

Could someone please help me with this as soon as possible. None of the
suggestions have worked so far. I have to get this working for year end
reporting. This is very important.

Thank you!
 

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