Newbies graphex Posted April 3, 2002 Newbies Posted April 3, 2002 riddle me this...I've got a 3 price fields for my products which are sold in 3 different size packages. When I calculate these prices into one text field, I'm losing all of the currency formatting of .00. for example: small $1.00 medium $2.00 large $3.00 my calc'd field is resulting in: small $l, medium $2, large $3. what I want to have is: small $1.00, medium $2.00, large $3.00. thanks in advance, Roger
Newbies graphex Posted April 4, 2002 Author Newbies Posted April 4, 2002 ** The original fields are number fields are they? -- Vaughan Bromfield, Sydney, Australia ** Yes. Roger [ April 03, 2002, 04:48 PM: Message edited by: graphex ]
slstrother Posted April 4, 2002 Posted April 4, 2002 Try this calc: "Small"&" "&"$"&NumToText(Int(Small))& Case(Mod(Small,1)=0,".00", Mod(Small,1) > 0 and Length(NumToText(Mod(Small,1)))=2,NumToText(Mod(Small,1))&"0", Mod(Small,1) > 0 and Length(NumToText(Mod(Small,1)))=3,NumToText(Mod(Small,1)))&", "& "Medium"&" "&"$"&NumToText(Int(Medium))& Case(Mod(Medium,1)=0,".00", Mod(Medium,1) > 0 and Length(NumToText(Mod(Medium,1)))=2,NumToText(Mod(Medium,1))&"0", Mod(Medium,1) > 0 and Length(NumToText(Mod(Medium,1)))=3,NumToText(Mod(Medium,1)))&", "& "Large"&" "&"$"&NumToText(Int(Large)& Case(Mod(Large,1)=0,".00", Mod(Large,1) > 0 and Length(NumToText(Mod(Large,1)))=2,NumToText(Mod(Large,1))&"0", Mod(Large,1) > 0 and Length(NumToText(Mod(Large,1)))=3,NumToText(Mod(Large,1)))) Hope this helps
Fitch Posted April 4, 2002 Posted April 4, 2002 Here's a slightly "cleaner" calc: "small $" & Left(NumToText(smallAmt + .001), Length(NumToText(smallAmt + .001)) - 1) & "medium $" & Left(NumToText(medAmt + .001), Length(NumToText(medAmt + .001)) - 1) & "large $" & Left(NumToText(largeAmt + .001), Length(NumToText(largeAmt + .001)) - 1) The way it works is, we add .001 to the numbers to ensure they have decimal digits, then we lop off that trailing "1" by first changing the number to text, then selecting only what is to the left of that trailing 1, that is, the length minus one.
djgogi Posted April 4, 2002 Posted April 4, 2002 code: CURRENCYSIGN & " " & Case( NUMBER < 0 , "-") & Choose( Abs( Round( NUMBER , PRECISION )) < 10^9 , Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^9 )) , 3 ) & "," ) & Choose( Abs( Round( NUMBER , PRECISION )) < 10^6 , Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^6 )) , 3 ) & "," ) & Choose( Abs( Round( NUMBER , PRECISION )) < 10^3 , Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^3 )) , 3 ) & "," ) & Right( Abs( Int( Round( NUMBER , PRECISION ))) , 3 ) & Choose( PRECISION = 0 , "." & Right( 10^PRECISION & Abs( Round( NUMBER , PRECISION ) ) * ( 10^PRECISION ) , PRECISION )) Where in uppercase are variables. This one would deal with decimal virgola too. (Result from discussion FMExperts list) HTH Dj
Fitch Posted April 4, 2002 Posted April 4, 2002 Dj, that's the second time today our posts have crossed in the mail! But amazingly, I think my solution is better for once. ciao
Newbies graphex Posted April 4, 2002 Author Newbies Posted April 4, 2002 To slstrother, Fitch & dj, Thanks a lot!!! Regards, Roger
ibiubu Posted April 9, 2002 Posted April 9, 2002 Holy cow! i could not believe the LENGTH of the calculation to accomplish something that in theory should be a simple task. Oh well, so much for my perfect world.
Recommended Posts
This topic is 8621 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now