Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If Fields Blank move Record Below into it's Space Post Reply Post New Topic
Author Message
jsh8286
Groupie
Groupie
Avatar

Joined: 09 Mar 2012
Online Status: Offline
Posts: 46
Quote jsh8286 Replybullet Topic: If Fields Blank move Record Below into it's Space
     Posted: 11 Jun 2013 at 2:08pm
As the subject indicates have a crystal report where I want to be able to move records up if the above record is blank above.
 
For example:
 
In a credit note for example I want to display some address information lide this:
 
Ship To Name
Ship To Address 1
Ship To Address 2
Ship To Address 3
Ship To Address 4
City, State, Zip
 
Now in a perfect world if the data is filled in all the above fields there is not issue. But depending on the customer in many instances Address lines 2, 3 and 4 sometimes are not applicable hence there is no information in them.
 
So when the credit note prints (this assumes in this example address lines 3 and 4 are blank) I get back the following:
 
Ship To Name
Ship To Address 1
Ship To Address 2
 
 
City, State, Zip
 
There are two blank lines. What I want is:
 
Ship To Name
Ship To Address 1
Ship To Address 2
City, State, Zip
 
So in this case since the above two lines returned a blank the City, State, Zip field moved up two spaces.
 
Any suggestions?
 
Thanks in advance.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 12 Jun 2013 at 2:32am
probably not the prettiest way, but this works for me:

create a formula like:

if not isnull({table.name}) and not isnull({table.address1}) and not isnull({table.address2}) and not isnull({table.address3}) and not isnull({table.address4}) then
{table.name} & Chr(13) & Chr(10) & {table.address1}) & Chr(13) & Chr(10) & {table.address2} & Chr(13) & Chr(10) & {table.address3} & Chr(13) & Chr(10) & {table.address4}

else
if not isnull({table.name}) and not isnull({table.address1}) and not isnull({table.address2}) and not isnull({table.address3}) and isnull({table.address4}) then
{table.name} & Chr(13) & Chr(10) & {table.address1}) & Chr(13) & Chr(10) & {table.address2} & Chr(13) & Chr(10) & {table.address3}

else etc etc etc

this will check if all the fields have a value. If they do, you show each field below each other. If one field is empty (in my example address4), this you simply don't include it in your output [IMG]smileys/smiley1.gif" align="middle" />

so for you example, it would be like
if not isnull({table.name}) and not isnull({table.address1}) and not isnull({table.address2}) and isnull({table.address3}) and isnull({table.address4}) then
{table.name} & Chr(13) & Chr(10) & {table.address1}) & Chr(13) & Chr(10) & {table.address2} & Chr(13) & Chr(10) & {table.City, State, Zip}

if City, State, Zip could be blank as well, you should take that in your equation as well

Edited by Gurbs - 12 Jun 2013 at 2:35am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Jun 2013 at 3:17am
you can also add seperate detail sections per address and set them each section to suppress when blank
or
you can add all fields with a carriage return into one big text field and set the text field property 'Suppress Embedded Field Blank Lines' as true


Edited by DBlank - 12 Jun 2013 at 3:17am
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