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

Percent Format in a Control

P: n/a
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
display 17% and hold the value of seventeen percent.

I have the control propertes set to the following:

Name: comflatpercent
Format: percent
Deciaml places: 2

When I try enter 17 or .17 the control displays 0%. How can I make this
work?

Thanks in advance!!

Michael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If the control is bound to a field in a table, make sure the field has a
floating point data type, like single, and make sure that the control is
formatted correctly. If you have the right data type and format and then
enter ".17", you should see 17%. However, if you want to enter "17" and then
see 17%, you need to have the form do the division by 100 for you, probably
in the control's AfterUpdate event:

Me![MyField] = Me![MyField]/100

"Nothing" <me@you.com> wrote in message
news:1102475343.b9be007a3c6a0e9712b7a44dcbd5cad4@t eranews...
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
display 17% and hold the value of seventeen percent.

I have the control propertes set to the following:

Name: comflatpercent
Format: percent
Deciaml places: 2

When I try enter 17 or .17 the control displays 0%. How can I make this
work?

Thanks in advance!!

Michael

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2

P: n/a
Here is an implementation of Dave's idea.

1. Paste the function below into a standard module (Modules tab of Database
windows).

2. Set the After Update property of any text box you wish to apply this to.
For example, if you have a text box named Discount, set its After Update
property to:
=MakePercent([Discount])

The code divides by 100 only if the user did not type the % character.

Public Function MakePercent(txt As TextBox)
If Not IsNull(txt) Then
If InStr(txt.Text, "%") = 0 Then
txt = txt / 100
End If
End If
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave M" <NO************@DROPTHISisland.net> wrote in message
news:GKutd.437236$Pl.383955@pd7tw1no...
If the control is bound to a field in a table, make sure the field has a
floating point data type, like single, and make sure that the control is
formatted correctly. If you have the right data type and format and then
enter ".17", you should see 17%. However, if you want to enter "17" and
then
see 17%, you need to have the form do the division by 100 for you,
probably
in the control's AfterUpdate event:

Me![MyField] = Me![MyField]/100

"Nothing" <me@you.com> wrote in message
news:1102475343.b9be007a3c6a0e9712b7a44dcbd5cad4@t eranews...
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
display 17% and hold the value of seventeen percent.

I have the control propertes set to the following:

Name: comflatpercent
Format: percent
Deciaml places: 2

When I try enter 17 or .17 the control displays 0%. How can I make this
work?

Thanks in advance!!

Michael

Nov 13 '05 #3

P: n/a
Thanks guys. That did the trick.

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.