Print Page | Close Window

Field formatting

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
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=12149
Printed Date: 05 May 2024 at 2:42am


Topic: Field formatting
Posted By: crystallize
Subject: Field formatting
Date Posted: 25 Jan 2011 at 5:24am
Hey,

I've got a question:

I've got a formula field. It's alignment is set to "right".
I want to print some dates, text, numbers ... with that formula field.
The formula looks like this:

{@Page_Number} + CHR(13)
+
Cstr({DatePrinted}, 'dd.MM.yyyy') + CHR(13)
+
(if (Length(Cstr(SupplierID})) > 0 ) then
Cstr(SupplierID}, '#') + CHR(13))
+
(if (Length(Cstr({CustomerID})) > 0 ) then
Cstr({CustomerID}) + CHR(13))


IMO the result must look like this:
1 of 4
15.01.2009
1234
5678

But it look like this:
1 of 4  
15.01.2009 
1234
5678

I want it to look like the first example.
Can you help me?

Thanks in advance



Replies:
Posted By: DBlank
Date Posted: 25 Jan 2011 at 6:02am
you might try and trim the items...
trim( mailto:%7b@Page_Number - {@Page_Number }) + CHR(13)
+
trim(Cstr({DatePrinted}, 'dd.MM.yyyy')) + CHR(13)
+
(if (Length(Cstr(SupplierID})) > 0 ) then
Cstr(SupplierID}, '#') + CHR(13))
+
(if (Length(Cstr({CustomerID})) > 0 ) then
Cstr({CustomerID}) + CHR(13))



Posted By: crystallize
Date Posted: 25 Jan 2011 at 9:44pm
Originally posted by DBlank

you might try and trim the items...
trim( mailto:%7b@Page_Number - {@Page_Number }) + CHR(13)
+
trim(Cstr({DatePrinted}, 'dd.MM.yyyy')) + CHR(13)
+
(if (Length(Cstr(SupplierID})) > 0 ) then
Cstr(SupplierID}, '#') + CHR(13))
+
(if (Length(Cstr({CustomerID})) > 0 ) then
Cstr({CustomerID}) + CHR(13))



Thx for your answer.
I already used "trim" but it changed nothing. Also I tried alot things in the "format editor" of that field.

Any other ideas?


Posted By: DBlank
Date Posted: 26 Jan 2011 at 4:17am
I cannot seem to replicate this problem however I replaced
your page number formula with the PageNofM print state property and datePrinted with the PrintDate property.
 
You can also try a text box
and drag and drop the 4 items you want into it with your carriage returns in the text box. Right click on each one and format them the way you want. Then right click on the text box and select format text, select common tab and check 'Suppress Embedded Field Line Blanks" as true. set it to Can grow and then make the box a height of 1 row. 
 


Posted By: crystallize
Date Posted: 26 Jan 2011 at 5:28am
Originally posted by DBlank

I cannot seem to replicate this problem however I replaced
your page number formula with the PageNofM print state property and datePrinted with the PrintDate property.
 
You can also try a text box
and drag and drop the 4 items you want into it with your carriage returns in the text box. Right click on each one and format them the way you want. Then right click on the text box and select format text, select common tab and check 'Suppress Embedded Field Line Blanks" as true. set it to Can grow and then make the box a height of 1 row. 
 


Thank you.
I tried it with the textbox, but it's still the same result.

It's not PageNumber-Formula or the DatePrinted-Field. I replaced them with hardcoded data and it's the same result Confused


Posted By: DBlank
Date Posted: 26 Jan 2011 at 5:45am
This is odd. I have seen a few other instances where people did not trim a field and when they right justified assuemd that there were no spaces on the end but not like this. Italmost seems to reading chr(13) as a space and a return.
I would try breaking this down. maybe try each of the fields individually as formula fields or fields dropped into text boxes and see fi they always replicate the problem. If they replicate try trimming on a fomrula field.
Do the individual fields repeat the problem?


Posted By: crystallize
Date Posted: 26 Jan 2011 at 10:02pm
Originally posted by DBlank


maybe try each of the fields individually as formula fields or fields dropped into text boxes and see fi they always replicate the problem. If they replicate try trimming on a fomrula field.
Do the individual fields repeat the problem?


Good morning,

I've tried the following:
First of all i created some formula fields (a formula-field for "{@Page_Number}" and a formula-field for  "Cstr({oSalesDocument_oSalesDocPrintedColl.dtDatePrinted}, 'dd.MM.yyyy')"
and so on.
Put them all into my report, same font/size and their alignment set to right.
Looks fine if I do it this way.

BUT the point is to get them all into one formula or even all formulas in the same textbox. The reason is, if I want to format them (change the font/size, position or other things I want to change only 1 field instead of 6).

Next try I've putted those formula-fields into a textbox...... ye, looks ugly again. Same problem.
I've tried trim, but it changed nothing.

*cry*

Edit:

I've just tried to put those formula-fields into a textbox again. But instead of putting them right into there under each other with a carriage return I've tried to set them in a row. Extended the formula-fields with a "CHR(13)" and tried it out........... damn, still the same ugly result =<



Posted By: DBlank
Date Posted: 27 Jan 2011 at 4:08am
I was recommending deconstructing your formula as a way to problem solve not necessarily as a final solution, however you do have a solution now if needed even if it is not the desired one.
I find breaking formulas into parts and testing each part a good problem solving process.
I still cannot replicate the issue in my test report (using PageNofM and PrintDate as stand ins for your formula).
What font and font size are you using?


Posted By: crystallize
Date Posted: 27 Jan 2011 at 4:18am
Originally posted by DBlank

What font and font size are you using?


Arial size 9.
I also tried many other (Times new roman, courier new ......)



Posted By: DBlank
Date Posted: 27 Jan 2011 at 4:27am

So I am interpretting the if statements of supplierID and customerID that you want them to exclude nulls or 0's.

Just to try it,
in the formula editor change the option in the pick list to Use Default values for Nulls and try the formula
(PageNofM + CHR(13))
+
(Cstr(PrintDate, 'dd.MM.yyyy') + CHR(13))
+
(if {SupplierID}> 0 ) then
Cstr({SupplierID},0,'') + CHR(13))
+
(if {CustomerID} > 0 ) then
Cstr({CustomerID},0,'') + CHR(13))


Posted By: crystallize
Date Posted: 27 Jan 2011 at 10:08pm
Originally posted by DBlank

(PageNofM + CHR(13))
+
(Cstr(PrintDate, 'dd.MM.yyyy') + CHR(13))
+
(if {SupplierID}> 0 ) then
Cstr({SupplierID},0,'') + CHR(13))
+
(if {CustomerID} > 0 ) then
Cstr({CustomerID},0,'') + CHR(13))


Good morning DBlank,

first of all, thank you for your time and your help!

I've tried this out, but it's the same result as before :/


EDIT:

I replaced "25.01.2011" with "25 01 2011". Looks kinda cool.
It seems that the "." between those numbers is smaller than any other sign.

But as you know i can't print a date without a "." between the numbers.
 :/

Any idea about that?

(But there is still the problem, that they aren't be  flush to each other.
If line 1 ends with an "1" and line 2 ends with a "5", they aren't be flush.

Line 1 ends with an "1"
Line 2 ends with an "1"
=
flush


Line 1 ends with an "1"
Line 2 ends with a "5"
=
not flush



Print Page | Close Window