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

Zero supression in string

Status
Not open for further replies.

bobgsysop

Programmer
Nov 3, 2000
25
US
Hi-

I have a 15 character string field that usually contains a zero filled number - like "00000000001234". Sometimes, however, the field may contain alpha characters.

So, I'd like to suppress the leading zeros, when the field is numeric, and print the whole field when non-numeric. I've tried to creatre a formula to do this:

If NumericText ({OEORDHDR_SQL.Cus_Alt_Adr_Cd}) Then
ToNumber ({OEORDHDR_SQL.Cus_Alt_Adr_Cd})
else
{OEORDHDR_SQL.Cus_Alt_Adr_Cd};

but on checking, I'm told "A number is required here" following the "else". Without the else, a zero is printed instead of the valid string. Conversely, if I change the formula to check "If Not NumericText" the error message tells me a string is required after the else.

Any ideas?

I'm using Crystal v8.

Thanks in advance.
BobG
 
Hi !

This maybe one way to solve your problem:

Declare a variable in your formula,
and then you can do your test again.

numberVar numfield;

If NumericText({OEORDHDR_SQL.Cus_Alt_Adr_Cd}) then
(
numfield := ToNumber({OEORDHDR_SQL.Cus_Alt_Adr_Cd});
ToText(numfield,0,"");
)
else
{OEORDHDR_SQL.Cus_Alt_Adr_Cd}

/Goran
 
BobG-

Another Macola user huh?

Macola has built UFLs that are distributed with their software that take care of this (provided that you buy crystal through them or their channel), and a whole lot of other stuff. If you give me an email address I have a 2 or 3 page document that goes over all this in brief.

Having said that, I rarely use these UFLs because I typically want my reports to work everywhere, provded that Macola data exists.

Give me your email address if you are interested in the document, and good luck. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Actually, I do contract work for a Macola dealer in New York. VB front ends, custom reports, etc. I don't have Macola's version of Crystal installed here, since I have the developer version from Crystal Decisions. However, I do have access to their UFLs.

Please send me the document you mentioned - bobg9_AT_ix._netcom_.com - remove all the underscores and replace "AT" with @.

Regards,
BobG

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top