Entering a percent

J

Jim Orson

Hi,

How do I enter a number directly as a percent in a form? If I enter 4.5 for
example, I want to display the number as 4.5% and store it as .045 for
report calculations. As it is now, I have to enter .045 to get the number
to display as 4.5% and store in the table as .045. Is there a setting I
need to change?

Thanks for help.

Jim...
 
D

Denny G.

For 100% and below, add this AfterUpdate procedure to
your text box on your form:

Sub MyTextBox_AfterUpdate()
If MyTextBox>1 then
MyTextBox=MyTextBox/100
End If
End Sub

Denny G.
 
J

Jim Orson

Denny G.

Thanks. It works great! The key was using the AfterUpdate procedure.

Jim...
 
D

Denny G.

Be sure to format the text box on your form as Percent in
the form's properties, and be sure to enter the percent
sign after entering the number or you will get an error
message.

Denny G.
 
J

Jim Orson

Denny G.

Hmmm. As I said in my other post, it works fine. Yes, the text box format
is set to Percent. But, I get no error message when I enter data without
the percent sign. I did change the sub by eliminating the if statement and
just using the /100 statement. I wanted it valid for all input, not just
greater than 1.
BTW, I am using Access 2003 if that means anything.

Jim...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top