Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Crystal Reports XI Display String Post Reply Post New Topic
Page  of 2 Next >>
Author Message
ifejza
Newbie
Newbie
Avatar

Joined: 22 Apr 2009
Location: Albania
Online Status: Offline
Posts: 11
Quote ifejza Replybullet Topic: Crystal Reports XI Display String
     Posted: 22 Apr 2009 at 1:12am
Hi,

I have a problem with Display String and Crystal Syntax.

I need to show/hide one text item in some cases.
For example

IF {abc} = 5 THEN
{def}.visible = TRUE
ELSE
{def}.visible = FALSE

This code is not write in right way, but I can't to find right way.

Imran
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Apr 2009 at 6:31am
put it in the suppression formula.  If it is a band, like details, you can use the Section Expert.  If it is a field or a formula, right click on it and select 'Format Field', general tab.  If it is a straight text field, make a formula that uses the same verbiage, since textboxes won't let you suppress them conditionally.
 
Now that we know where to suppress the item, what is the syntax.  All that suppression wants is true or false, so you can enter something as simple as:
 
{abc} <> 5
 
when {abc}=5, the statement is false, and the item is NOT suppressed...it's a bit backwards, but makes sense once you use it often enough.
 
IP IP Logged
ifejza
Newbie
Newbie
Avatar

Joined: 22 Apr 2009
Location: Albania
Online Status: Offline
Posts: 11
Quote ifejza Replybullet Posted: 22 Apr 2009 at 6:50am
Thanks lockwelle,

I try to explain much better .
If in One Text Item (abc), I have specific string in this case I want to see some text in Second Text Item (def), but in opposite Second Text Item must be Hide. Both Text Item are from SQL statement.

I write the code in Format Editor --> Common (tab) --> Display String

Example
IF {abc} = ‘Today is Wednesday’ THEN
{def}.visible = TRUE (I must see text “Yes, Today is…”)
ELSE
{def}.visible = FALSE
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Apr 2009 at 7:04am
As far as 'seeing' a field or it being 'visible' Crystal uses the term Suppress.  If an item is suppressed, it is not visible, this can be done all the time or based on some logic (conditionally). 
 
It sounds like you want to conditionally suppress a field, click the 'x-2' button next to suppress, then using your example you would enter:
IF {abc} = ‘Today is Wednesday’ THEN
  FALSE //(I must see text “Yes, Today is…”)  Don't suppress
ELSE 
  True //suppress or hide the field 
 
which is the same logically as:
{abc} <> ‘Today is Wednesday’
 
all that the formula is looking for is a boolean, true-hide the item or false-show the item.
 
hope this is clearer.
IP IP Logged
ifejza
Newbie
Newbie
Avatar

Joined: 22 Apr 2009
Location: Albania
Online Status: Offline
Posts: 11
Quote ifejza Replybullet Posted: 22 Apr 2009 at 8:10am
Thanks lockwelle,

This is what I want.

Imran,
IP IP Logged
ifejza
Newbie
Newbie
Avatar

Joined: 22 Apr 2009
Location: Albania
Online Status: Offline
Posts: 11
Quote ifejza Replybullet Posted: 23 Apr 2009 at 2:39pm
I have one more problem which related with previous.
In group header 1 first field in the row is Text Item AAA.
In group header 2 first field in the row is Text Item BBB.
In detail first field in the row is Text Item CCC.
Text Item AAA include Countries (USA, Canada, UK, Germany).
IF Text Item AAA equal with USA or UK THEN Text Item BBB SHOW ELSE HIDE.
Text Item BBB include cities from Countries.
Text Item CCC include Tax, Customs, Other Tax from each cities.

USA
Chicago
    Tax
    Customs
    Other Tax
Las Vegas
    Tax
    Customs
    Other Tax
Detroit
    Tax
    Customs
    Other Tax

Canada
    Tax
    Customs
    Other Tax
    Tax
    Customs
    Other Tax
    Tax
    Customs
    Other Tax

In Canada I need to GROUP Tax, Customs, Other Tax. I want to see only 3 rows.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Apr 2009 at 6:57pm
YOu can group on Country (AAA) then City (BBB) then Tax type (CCC) and suppress the details.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Apr 2009 at 7:07pm

Oops, this won't quite work. I see now that you are suppressing the city name which is causing the duplications.

I think I would create a formula for the second grouping instead of using the city name.
if {table.country} in ["USA","UK"] then {table.city} else {table.country}
Replace group 2 with this formula field and conditionally suppress it the same way you did before then add in group level 3 on the taxtype field (ccc) and supress the details rows.
 


Edited by DBlank - 23 Apr 2009 at 7:08pm
IP IP Logged
ifejza
Newbie
Newbie
Avatar

Joined: 22 Apr 2009
Location: Albania
Online Status: Offline
Posts: 11
Quote ifejza Replybullet Posted: 24 Apr 2009 at 12:30am
In group header 2 Text Item BBB Format Editor --> Suppress, I write
IF {AAA} IN [“USA”, “UK”] THEN
    FALSE
ELSE
    TRUE

For first part this code is OK and result is
USA
Chicago
    Tax
    Customs
    Other Tax
Las Vegas
    Tax
    Customs
    Other Tax
Detroit
    Tax
    Customs
    Other Tax

Canada
    Tax
    Customs
    Other Tax
    Tax
    Customs
    Other Tax
    Tax
    Customs
    Other Tax


If replaced this code with
if {AAA} in ["USA","UK"] then {BBB} else { AAA }
then have “The formula result must be a boolean”
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 24 Apr 2009 at 6:27am
The first thought that comes to mind is to create a formula like:
 
if {AAA} in ["USA","UK"] then
 {AAA}+{BBB}+{CCC}
else
 {AAA}+{CCC}
 
and use this formula to group on.  This will give dynamic grouping.  I am not sure if it will work, as I have tried to change the grouping of a report based on data fields...I usually change the grouping based on parameters,  but it is worth a try.
IP IP Logged
Page  of 2 Next >>
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