Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Suppressing blank fields in concatenated field Post Reply Post New Topic
Author Message
Kwirky
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Online Status: Offline
Posts: 32
Quote Kwirky Replybullet Topic: Suppressing blank fields in concatenated field
     Posted: 30 Nov 2010 at 1:25pm
Hi,
We have a field within MainPurchaseOrder.DeliverAddress which is automatically concatenated through a stored procedure. We are using this in a purchase order created using CR XI.
The problem is that sometimes one or all of Address2, Address3 and Address4 are blank in the original table which is used for the concatenation.
Is there a way to suppress the blank lines which appear when selecting "can grow".
We cannot amend the table directly.

ABC Pty Ltd
123 First Street
<blank>
<blank>
<blank>
Neverland
VIC
Australia
1234
03 1234 56789
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Dec 2010 at 3:17am
if you know what the field looks like, you can do a replace. Something like:
 
local stringvar crlf := chrw(13) + chrw(10);
local stringvar x := {MainPurchaseOrder.DeliverAddress};
x := Replace(x, crlf+crlf, crlf);
x
 
Then use the formula in the report in place of MainPurchaseOrder.DeliverAddress.
 
This should do it...if the blank lines are just crlf, if there is a space or something else in there, you would need to code for that.
 
Hopefully, this points you a direction that works
IP IP Logged
Kwirky
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Online Status: Offline
Posts: 32
Quote Kwirky Replybullet Posted: 01 Dec 2010 at 10:14am
Thanks for that. It worked almost perfectly. It has suppressed 2 of the blank lines, just leaves one more blank. Will this work regardless of how many of the 3 fields are left blank?

If it is not too much trouble could you explain the formula as my experience with formulas tends to be only the simple ones (have only been creating reports for about 6 months). Star

Thanks again.


Edited by Kwirky - 01 Dec 2010 at 11:00am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 02 Dec 2010 at 3:59am
it should.  You would have to see if there were any characters in the line that was not suppressed.  As a suggestion, you can also just repeat the x:=replace(...) command and see if that helps
 
an explanation of the formula.
the carriage return linefeed is actually 2 characters, 1 for the carriage return and 1 for the linefeed, respectively they are ASCII characters 13 and 10, so first I declare a local variable (which will disappear at the end of the formula) and assign it the value of ASCII characters that make up the carriage return linefeed.
 
Next I create and assign a local variable to hold the output from the stored proc.
 
I then replace all the occurrances of 2 carriage return/linefeed combinations that are next to each other (signifyng a blank line). This should replace all the blank lines with just 1 crlf.
 
So if a line looks like LINE1crlf  crlfLINE3, the replace won't work(you won't get LINE1crlfLINE3)as the line doesn't match the search pattern, but LINE1 crlfcrlfLINE3 does match the pattern and you should see LINE1crlfLINE3.
 
Last, just because I'm not sure and wanted to cover all bases, I have the formula display the new value of x.  I might have displayed this anyhow, but I just wanted t be sure.
 
HTH
IP IP Logged
Kwirky
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Online Status: Offline
Posts: 32
Quote Kwirky Replybullet Posted: 02 Dec 2010 at 9:39am
Thanks so much :)
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum