|
 |
access thread: Formatting % in Access 2000
Message #1 by "Anonymous on Mon, 21 Jan 2002 22:53:13
|
|
Hi,
I am using the percent format and datatype in one of my forms. But every
figure that is put into the textbox is multiplied by 100 and the % added
on at the end. So, if a user enters 10 into the textbox and tabs to the
next control, it appears as 1000%. (He needs to enter .1 into the textbox
for it to come up as 10%)
Is there any way, I can format this, so that he can enter a number and a %
will appear at the end of it. I tried using [fieldname & "%"] in the
formatting box, but that didn't work.
Thanks guys!
Message #2 by "Richard" <richard@a...> on Mon, 21 Jan 2002 17:26:22 -0800
|
|
I handle the situation by checking to see if the number entered is
larger than 1 and if it is I divide by 100. The reason for thecheck is
just in case the user did put it in correctly I want to leave it alone.
Private Sub_CheckNumber(sometextbox)
if sometextbox > 1 then sometextbox=sometextbox/100
End sub
Call this sub when the control loses focus. Do not call this sub at the
change event since the check will happen too soon.
Hope this helps.
Richard
richard@a... <mailto:richard@a...>
Cell: (xxx) xxx-xxxx
Fax: (xxx) xxx-xxxx
****ORIGINAL MESSAGE*******
I am using the percent format and datatype in one of my forms. But
every
figure that is put into the textbox is multiplied by 100 and the % added
on at the end. So, if a user enters 10 into the textbox and tabs to the
next control, it appears as 1000%. (He needs to enter .1 into the
textbox
for it to come up as 10%)
Message #3 by Anonymous on Tue, 22 Jan 2002 04:42:29 +0000
|
|
<html><div style='background-color:'><DIV>
<P> </P>
<P>Hi Richard,</P>
<P>Thanks for your advice. I changed the code slightly, but works fine, so now they can input as a decimal figure or
a whole number and it comes up as a percentage.</P>
<P>I made sure they realised they could never use a percentage figure less than 1% for this to work, but they seem happy, so
that's the main thing.</P>
<P>Thanks for your help.</P><P>Private Sub txtPercentage_LostFocus()</P>
<P> Dim numPercentage As Single<BR>
<BR> numPercentage = CSng(txtPercentage.Text)<BR>
<BR> If numPercentage < 1 And numPercentage > 0
Then<BR> numPercentage = numPercentage *
100<BR> End If<BR> <BR>
txtPercentage.Text = numPercentage & "%"<BR>
<BR>End Sub</P>
<DIV></DIV>
<DIV></DIV>
<P>>From: "Richard" <RICHARD@A...></P></DIV>
<DIV></DIV>>Reply-To: "Access" <ACCESS@P...>
<DIV></DIV>>To: "Access" <ACCESS@P...>
<DIV></DIV>>Subject: [access] RE: Formatting % in Access 2000
<DIV></DIV>>Date: Mon, 21 Jan 2002 17:26:22 -0800
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>I handle the situation by checking to see if the number entered is
<DIV></DIV>>larger than 1 and if it is I divide by 100. The reason for thecheck is
<DIV></DIV>>just in case the user did put it in correctly I want to leave it alone.
<DIV></DIV>>Private Sub_CheckNumber(sometextbox)
<DIV></DIV>> if sometextbox > 1 then sometextbox=sometextbox/100
<DIV></DIV>>End sub
<DIV></DIV>>
<DIV></DIV>>Call this sub when the control loses focus. Do not call this sub at the
<DIV></DIV>>change event since the check will happen too soon.
<DIV></DIV>>Hope this helps.
<DIV></DIV>>
<DIV></DIV>>Richard
<DIV></DIV>&DIV></DIV>>richard@a... <?xml:namespace prefix = mailto /><mailto:richard@a...
<DIV></DIV>>Cell: (xxx) xxx-xxxx
<DIV></DIV>>Fax: (xxx) xxx-xxxx
<DIV></DIV>>
<DIV></DIV>>****ORIGINAL MESSAGE*******
<DIV></DIV>>I am using the percent format and datatype in one of my forms. But
<DIV></DIV>>every
<DIV></DIV>>figure that is put into the textbox is multiplied by 100 and the % added
<DIV></DIV>>
<DIV></DIV>>on at the end. So, if a user enters 10 into the textbox and tabs to the
<DIV></DIV>>
<DIV></DIV>>next control, it appears as 1000%. (He needs to enter .1 into the
<DIV></DIV>>textbox
<DIV></DIV>>for it to come up as 10%)
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>---
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV></mailto:richard@a...</div><br clear=all><hr>Chat with friends online, try MSN
Messenger: <a href='http://go.msn.com/bql/hmtag1_etl_EN.asp'>Click Here</a><br></html>
|
|
 |