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

Concatenating a print line with variable length fields

Status
Not open for further replies.

jsteff

Technical User
May 22, 2003
109
US
Crystal 8.5

Here is my formula:
-----------------------------
If {MiscChg.PayAmt} > 0
then
space(5)+Cstr({MiscChg.Units},0,"")+space(8)+{@ConvertUnitCodeToWord}+space(8)+{MiscChg.Descr}+space(8)+Cstr({MiscChg.PayAmt})
------------------------------
I have two problems:
1. MiscChg.Descr is not a fixed length so the PayAmt is not aligned vertically. How do I fix the length of the Descr?

2. When the PayAmt is zero, it prints a blank line. How can I prevent this?

Thank you!




 
As to the fixed length problem:

left({MiscChg.Descr} & space(30),30) (VB code)

will always give you a fixed size field (Change the 30's to whatever).. Use courier (non-proportional font) if you have many fields to display and they need to line up on the report...

Rich..
 
As to the blank line, go to format section->details and check "suppress blank section."

-LB
 
I think that Rich fielded that very nicely, except for the If 0 blank line problem.

What is it you want to print if it's 0? If nothing, limit the rows in the report by selecting report->edit selection formula->record and placing something like the follwing in there:

{MiscChg.PayAmt} > 0

If you want something to pirnt, add in an else to your formula, such as:

If {MiscChg.PayAmt} > 0
then
space(5)+Cstr({MiscChg.Units},0,"")+space(8)+{@ConvertUnitCodeToWord}+space(8)+{MiscChg.Descr}+space(8)+Cstr({MiscChg.PayAmt})
else
"Gets no dough..." //or whatever

-k
 
If you want razor sharp edges to your column lineups...do not do the whole thing in a single formula.

Even the solution proposed by "RICH" will not yield what you are looking for unless you are dealing with a boring proportional font. IE. a string 15 chars plus 5 blanks will be longer or shorter than a string of 10 chars plus 10 blanks...just the nature of the fonts...not much can be done

How ever you appear to be displaying 4 values:
(1) Cstr({MiscChg.Units},0,"")
(2) {@ConvertUnitCodeToWord}
(3) {MiscChg.Descr)
(4) Cstr({MiscChg.PayAmt})

Place these in a section in separate fields whose size will handle their expected range of values And your results will be perfect.

As far as your second problem goes...the "zero" payment is probably not a true zero but rather a NULL so the whole formula fails and you get a blank line.

My solution would leave you with the rest of the information intact. You can handle the payment formula for (4) by making your formula

@Payment

WhilePrintingRecords;

if not isnull({MiscChg.PayAmt}) or
length(trim({MiscChg.PayAmt}) <> 0 then
Cstr({MiscChg.PayAmt})
else
&quot;0.00&quot; // or a message or whatever

Hope this helps






Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top