By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

SImple Percent Format Question

P: 16
Hello,

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
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 446
Hi
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
  2.  
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.
S7
Dec 2 '11 #2

P: 16
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

Expert 100+
P: 446
Yes,
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!
S7
Dec 2 '11 #4

Expert 100+
P: 446
Cabnabs,
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!
S7
Dec 2 '11 #5

P: 16
sierra7
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

P: 16
sierra7
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

NeoPa
Expert Mod 15k+
P: 31,186
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

100+
P: 759
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.