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

Crystal formats zip code as number with comma. 1

Status
Not open for further replies.

Zarobi

Technical User
Feb 19, 2004
13
US
I'm mail-merging an address list from an Excel spreadsheet into a letter in Crystal. In the spreadsheet, the Zip Code is formatted with the special Postal Code formatting that displays leading zeros (eg: 04512 instead of 4512). When I view the field in the Crystal letter, the zip code displays as 4,512.00. If I apply formatting to remove the comma and zeros, I get 4512.

So I tried to explicitly convert it with a formula:

if Len(CStr({MailList.Zip})) = 4
then "0" & CStr({MailList.Zip})
else CStr({MailList.Zip});

But I found that in order to accomplish this, I needed to convert the zip code to a string. This formula still results in a display of 4,512.00.

The strange thing is that I've run this letter every week for the last 3 months and have not encountered this problem until now. The source data has not changed. The only change has been my operating system. We upgraded to XP on Friday. Though I'm not sure how this would affect how Crystal formats numbers.
 
If it helps, we're using Crystal Reports Standard (Full) version 9.2.2.634.
 
Try:

if Len(CStr({MailList.Zip})) = 4
then "0" & CStr({MailList.Zip},0,"")
else CStr({MailList.Zip},0,"")

I think you could also use:

cstr({MailList.Zip},"00000")

-LB
 
Assuming that it's always 5 digits, you won't need a conditional:

right("0"+totext(1111,0,""),5)

-k
 
I still don't know why it would have changed the number format in the report, but lbass' suggestion worked. Thanks so much for a sweet, simple solution :)
 
Hmmm, odd that mine didn't work. I can understand the XP upgrade creating the issue, but I can't understand why mine didn't work.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top