473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SImple Percent Format Question

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
8 7920
sierra7
446 Expert 256MB
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
Cabnabs
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
sierra7
446 Expert 256MB
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
sierra7
446 Expert 256MB
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
Cabnabs
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
Cabnabs
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
32,556 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
Mihail
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

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

Similar topics

3
by: Nothing | last post by:
This is going to be a really stupid question, but I am having a problem with the percent format in a control on a form. My end goal is that I want the user to enter 17 and have the control...
0
by: Cat | last post by:
Hello. I have an integer whose value varies from 0 to 9999. I want to print it in a four-digit format. Like, 0000 0001 0002 ..... 9998 9999
4
by: Fred Nelson | last post by:
Hi: I'm very new to vb.net and I apologize if this question should have been found in the documentation however I don't understand the documentation. I have a textbox on a vb.net web form that...
7
by: Steven D'Aprano | last post by:
I have a sinking feeling I'm missing something really, really simple. I'm looking for a format string similar to '%.3f' except that trailing zeroes are not included. To give some examples: ...
9
by: arnuld | last post by:
hello folks, i have a simple one line question. i am planniing to 1st learn Assembly & then C++: are there any jobs that i can get by learning C++? -- if yes, what type of jobs are...
2
by: tom c | last post by:
I want to put the date in Year, Month, Day format so todays date, 7/8/2006, will give me 20060708. The following code code leaves out the zeros for day and month and gives me 200678 Dim...
1
by: parthis | last post by:
Hi, I am new to Access and working a Report to display a Percentage value. The value in db is a text with value 23 But when i apply Format = Percent in design view of Reports it renders it...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
4
by: plaguna | last post by:
Every time I calculate numbers to get a percent format type in a query It gives me a big number. For instance: 7689.43% instead of 76.89%. I tried every possibility in the Property Sheet and It...
3
by: civettina | last post by:
Hi, I'm trying to send an email to' sample@sample.com' when a new row on my table contactform_con is inserted. Basically, when a person fills out the contact form (contactform_con) I want one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.