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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Too many arguments ..." error in ToText function

Status
Not open for further replies.

sk1955

Programmer
Jul 2, 2002
3
CA
I have field ot type string, that may contain characters or numbers. If it is a number - I want print it in the report with thousands separator - ",". But formula, that I create:

If NumericText({pt_get_summary_report.DATA2}) Then
ToText({DATA2}, 3, ",", ".")
Else
{DATA2}

gave me the "Too many arguments have been given to this function" error.
I tried
ToText({DATA2}, "#,###,###.000")
but with the same result.
I use Crystal Report 8.5.

Please help - what am I doing wrong?
 
Try:

If NumericText({pt_get_summary_report.DATA2}) Then
ToText(CDbl({DATA2}), 3, ",", ".")
Else
{DATA2}

Cheers,
- Ido
CUT (Crystal UTilities): e-mailing, exporting, electronic bursting & distribution of Crystal Reports:
 
Use this instead:

if numerictext({pt_get_summary_report.DATA2})
then totext(tonumber({@DATA2})) else {@DATA2}

Naith
 
Thank You Ido!
It work perfect.

Sergey
 
Didn't see Ido's response. "CDbl" will do you, too - probably better in your case, as it gives you 3 decimal places.

Naith
 
If NumericText({pt_get_summary_report.DATA2}) Then
ToText({DATA2}, 3, ",", ".")
Else
{DATA2}
************************************************
{DATA2} = {pt_get_summary_report.DATA2}

I am assuming that this was a typo

your problem is that the string is already in text ...you are wanting to insert the thousand separator and decimal point? Then the proper way is to convert it to a number then back to text using toText. You don't have to specify the comma and period since these are applied as defaults


If NumericText({pt_get_summary_report.DATA2}) Then
ToText(tonumber({pt_get_summary_report.DATA2})},3)
Else
{pt_get_summary_report.DATA2};

this will convert numeric text to a rounded to 3 decimal number with period and comma
Jim Broadbent
 
Thank You Ido, Naith and Ngolem!

ToText(ToNumber({pt_get_summary_report.DATA2}), 3)

look better, because it use defaults.

Again thank You all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top