Print Page | Close Window

Converting Truncated Number to String Issue

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6046
Printed Date: 23 May 2024 at 3:48pm


Topic: Converting Truncated Number to String Issue
Posted By: CRG2009
Subject: Converting Truncated Number to String Issue
Date Posted: 10 Apr 2009 at 8:39am
I am having trouble with the formatting of 2 fields I would like to join.  First I am truncating an AUTO_KEY in a number format to remove the decimals using the following formula: truncate ({AUTO_KEY}) Everything works great and my number shows up as "12345"
 
I then want to convert the formula to a string using the following formula: cstr (truncate ({AUTO_KEY})) Everything works great and my string shows up as "12345".
 
I now want to add a "C" at the end of this string using the following formula: (cstr (truncate ({AUTO_KEY})) + 'C') Everything works great and my new string shows up as "12345C".
 
In Crystal 2008 the formatting is exactly how I want to see it.  When I open this report with another program such as Logicty Viewer, the truncating feature does not work and my field shows the decimal places again as "12345.00C".
 
I want to eventually convert this to a barcode and I can't have the decimal places.
 
I believe the problem is when the truncated AUTO_KEY is converted to a string.  Any ideas for a fix would be greatly appreciated.


-------------
CRG2009



Replies:
Posted By: lockwelle
Date Posted: 14 Apr 2009 at 6:43am
You could try converting to text first then trimming the decimals and finally adding the 'C'.  something like:
 
totext({auto_key}, 0, "") + 'C'



Print Page | Close Window