Print Page | Close Window

Number to String formatting

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3354
Printed Date: 02 May 2024 at 1:52am


Topic: Number to String formatting
Posted By: dansken
Subject: Number to String formatting
Date Posted: 05 Jun 2008 at 12:22pm
I have a number field that can have 0 to 4 decimals.  I use the following code to format the decimals to not show trailing zeros.

if right(ToText(CurrentFieldValue,4),4) = "0000" then 0 else
if right(ToText(CurrentFieldValue,4),3) = "000" then 1 else
if right(ToText(CurrentFieldValue,4),2) = "00" then 2 else
if right(ToText(CurrentFieldValue,4),1) = "0" then 3 else 4


I have now been asked to create a second field that has this information in a barcoded format.  We use Precision IDs barcode package for 128 and it demands that the field is a string.  The function looks like this:

PrecisionID_C128_A ({CRYSTAL_PICKPLANS.QTY_PICKED})

If I add a ToText to the number field I loose my decimal formatting.

PrecisionID_C128_A (ToText({CRYSTAL_PICKPLANS.QTY_PICKED}))

How can I convert my number to a string keeping the decimal formatting?

Thanks,


-------------
--
Magnus Andersen



Print Page | Close Window