Full Version: Changing Last 2 Digits To A Decimal
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
johan
How can change last to digits in a currency field to a decimal. In other words if I enter 12345 in should display as 123.45
Peter46
This sounds like quite a dangersous thing to do.
But you can use the afterupdate event procedure and do..


Me.textboxname = nz(me.textboxname)/100

johan
Thanx Peter46. I know it's a bit dangerous but it makes value inputs eazier and quicker
BruceM
QUOTE
it makes value inputs eazier and quicker

As long as everybody knows to enter the decimal part of the value even if it is 0.
johan
Bruce I'm aware of that. I will send communique in this regard to the users. Thanx for the info
Bob G
I know that the below code is syntaxtually incorrect but I am in a hurry and wanted to at least get it posted.
wouldnt you need to consider if the user entered it with a decimal in the first place?

Me.textboxname = iif(instt(1,me.textboxname,"."),,nz(me.textboxname)/100)
BruceM
QUOTE
I will send communique in this regard to the users

If that reminder is enough, where can I get some of your users? laugh.gif

To fill out Bob's suggestion a little, maybe something like:

Me.Textboxname = IIf(InStr(Me.Textboxname,".") > 0, Me.TextBoxName, Nz(Me.Textboxname,0)/100)
fkegley
You could also use the KeyPress event to do this couldn't you? You could test each ASCII code for digit or decimal point. If digit, join to previous entry, if decimal point, then if no decimal point already, join to previous entry. Once decimal point entered only allow at most two more digits. Then use Format function in AfterUpdate event of text box to present the entry as desired.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.