Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding thousand-separators in formual fields 1

Status
Not open for further replies.

Madawc

Programmer
Sep 5, 2002
7,628
GB
I know how to use totext ({myrec.Accno}, "") to remove commas as thousand-separators, when this is the norm. But can one do the reverse?

It's a problem for me because the data warehouse uses 'number' for a mix of quantity-fields and numeric codes. It's less work to treat them all as codes and adjust the quantities, when they are individual fields. But within a formula fields, is there anything I can do?

I am using Crystal 8.5 on Windows NT Madawc Williams
East Anglia
Great Britain
 
Please supply an example of what your field looks like and what you want for results.

Mike
If you're not part of the solution, you're part of the precipitate.
 
If I have {myrec.count}, I would like a formula field that would output something like [The text was 1,245]. I'd get this if {myrec.count} was a number and numbers defaulted to thousands. But if numbers do not default to thousands, I would get [The text was 1245].

I could of course define [The text was], or a more complex formula field with variable text, and then attach {myrec.count} to the end of it. But that would not work for more compelex cases, where I want a field to be ignored in the text if it is not relevant. Madawc Williams
East Anglia
Great Britain
 
Are your fields string type with numbers in them?
I'm still not entirely sure what you are looking for. If the follwong doesn't work, please suppliy examples from your table and what you want for results.

val({your.field}) will give you the number part of your filed if the number part is first in your field.
vla("123text") will resutl in 123, whlie val("text123") will result in 0.
Mike
If you're not part of the solution, you're part of the precipitate.
 
Have you tried CDbl then CStr but leave the thousand separator as default? Juan
Scotland (currently)
 
Sorry, exact :
cstr(cdbl("2000"))

This gives 2,000.00 Juan
Scotland (currently)
 
I finally solved it myself

cstr ({myrec.numvalue}, "#,###,###") in a formula field will show a value like 4000 as 4,000, and 1234567 as 1,234,567. This can then be placed in a text string and print correctly. The only drawback is that spacing is a shade excessive. Madawc Williams
East Anglia
Great Britain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top