Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentage field 1

Status
Not open for further replies.

EddieShack

Technical User
Mar 11, 2001
3
0
0
CA
Hi
I am pretty new at this, so it may sound stupid. I have a field that needs to be in a percent format. Whenever I enter a value, such as '5', it comes out as '%500'. Is there any way in one of the events for this field to change the value to '%5'. Like I said, I am very new to this, so it is probably something really easy. Any help appreciated.
 
If you have the format set to Percent then it will automagically multiply it by 100 ("percent" = "of one hundred" or "x 100").
You can just enter .05 or add some code that divides the input value by 100. Not real elegant.

Mike
 
Hi EddieShack,
This is by no means a stupid question! Those percent fields drive lots of people nuts! Here's a solution you could try:

First make sure that your field in the table is a Number field, "Single" size and Format set to percent.

Now on the field on your form: When your form is in design view, double-click on the field to bring up its properties dialog. Select the "Data" tab and find "Validation Rule". Enter this:
Between 0 And 1

On the next line down you'll find "Validation Text". This is what you can "say" to the user when they don't follow the "Rule". Enter this:

Please enter a value and a percent sign.

This field should have a "Format" that is percent, and "Decimal Places" 0.
Try this and see how you like it. If you read up a bit on each of these properties you are bound to find one you'll be happy with.

P.S. A quick way to call up help on any property is to set your cursor on its "field" and click F1. Good luck,



Gord
ghubbell@total.net
 
Thanks for all the help guys. Is there any way I could just divide the value by 100 or multiply by 0.01 in the afterupdate event? If there is, what is the proper syntax I would use. This is what I have been trying to do, but with no luck.
 
There's a couple of key words there Eddie: "No Luck". This field is really a window thru to the data in the table, so unless you are using this form for data entry only, the numbers you see might be a bit screwy. You could probably rig something with enough patience however please, give our other choices a shot. Gord
ghubbell@total.net
 
Thanks again for the help. I believe I found the answer. In the after update event, I added the following code:

Me.fieldname = [fieldname] * "0.01"
Me.Requery

This seems to be working for me. Thanks again guys.
 
Gord,
Great examples on making use of the validation properties as well as the percent ideas. I went back to a situation I recalled from earlier (and had pasted in a lame-o workaround) and adjusted it more along the lines you suggested above. MUCH better. :)

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top