469,292 Members | 1,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,292 developers. It's quick & easy.

SImple Percent Format Question


I am hoping someone can answer a simple question for me. I am using Access 2007. I am working with a percentage field and the field works fine in the table, query, and report. However in my Form I am using the following simple code:

Me.Hours_Worked = Me.Hours_Worked / 80

Question: How do I get the format to appear as a percentage on the form (for simplicity from the user perspective)? It appears as a decimal, such as [1] - which shows as 100% on the table and report, which is what I want but potentially confusing to a user.

Thanks in Advance,
I love this forum
Dec 2 '11 #1
8 7618
446 Expert 256MB
For a Text box to display the contents as Percent, select it in Design mode then on the 'Format Tab' set the Format property to 'Percent', then the number of decimal places you require.

I'm not sure about Access 2007, but Access 2003 will show the contents '2' as 200% (which is why I never used it!). Access 2010 will show it as 2%.

But your code sample worries me!
Expand|Select|Wrap|Line Numbers
  1. Me.Hours_Worked = Me.Hours_Worked / 80
When do you set it ? I should think the TextBox should have a Name of "txtHoursWorked" and then the Data Control Source "=[Hours_Worked]/80"
otherwise you will run the risk of storing hours worked divided by 80, back in your database.
Dec 2 '11 #2
Sierra7, Im sorry I should have explained that the database tracks hours by pay periods. And our Pay Periods are 80 hours. Thats why i used 80 versus 100.

So what happens is, a record is entered on my form that is 40 hours a pay period and it converts the 40 hours to 50% on the table. For my use thats perfect. But for the user, I would like them to see 50% not .50 . Is it simple format function?
Dec 2 '11 #3
446 Expert 256MB
my last post told you how to use the built-in function to do that.

I seem to work 80 hours a week too ;-o) no probs!
Dec 2 '11 #4
446 Expert 256MB
I'm very sorry but I have just been playing with the Percent format in Access 2010 and found it is working quite strangely.

If I type in .5 it displays 50.00%, but if I type in 0.5 it displays 0.50%

If I put a formula in the Control Source it ignore the Percent formatting altogether!(you can add formatting as shown below)

If it is bound to a field then 1 = 100%

If you have a TextBox txtPC and a database field Working_Hours then you can set the display of txtPC by setting it's Control Source to:
Expand|Select|Wrap|Line Numbers
  1. =Format([Working_Hours],"Percent")
I see why you have a problem!
Dec 2 '11 #5
I set my field size to single in the design view of the table, it seemed to recify that issue. Now, If I could just figure out how to make the form input appear as a percent and not a decimal. I played around with your format formula, but no luck so far.
Dec 2 '11 #6
Resolved my problem, I set the field on the table to percent, and field size as single, and set the format on the form to percent also. DUHH! SO now when the user enter 40 hours, the after update displays 50% and the table/report displays it as 50% also. I knew it was something simple, I was having a brain spasm. Thanks for your suggestions.
Dec 2 '11 #7
32,173 Expert Mod 16PB
You need to select one of S7's posts as Best Answer then Cabnabs. It is only on very rare occasions that we allow members to select their own posts as Best Answer, and this isn't one of them I'm afraid.
Dec 2 '11 #8
759 512MB
More one thing, Cabnabs.

In time I had a lot of trouble using SINGLE in my tables.
Even I need to replace the "Single" format with "Double" in ALL fields in ALL tables. And that in context I need only 6 decimals.
I advice you to use DOUBLE, even if this will increase the size for your database.

Of course it is your choice.
Dec 3 '11 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Nothing | last post: by
4 posts views Thread by Fred Nelson | last post: by
7 posts views Thread by Steven D'Aprano | last post: by
9 posts views Thread by arnuld | last post: by
2 posts views Thread by tom c | last post: by
30 posts views Thread by galiorenye | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.