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

Formula to suppress a section conditionally

Status
Not open for further replies.
Aug 27, 2003
428
0
0
US
Hi,

I am using Crystal Reports with VB Dot Net. I have a section with a double line. I need to suppress the double line conditionally based on the value of a field.

I tried the formula as

not ({Detail.HoldBack} <> 0) but this did not work. I also tried ({Detail.HoldBack} <> 0) but this did not work either.

When the field Detail.HoldBack is set to 1, I want to suppress teh section containing the double line. Else I want to show the double line.
 
I would like to add that both

not ({Detail.HoldBack} <> 0) and ({Detail.HoldBack} <> 0) work when the field is set to 1 and the double line does not show up. However, when the field is set to 0, the double line still does not show up.

Thanks in advance
juntion123
 
I also have two other fields that need to be checked soI modified the formula to suppress the section as :

{Detail.LehmanHoldBack} = 1 or {Detail.HoldBack} = 1 or {Detail.Interest} = 1

This did nto work too. When the values are set to 1, the double line still shows up.
 
The below formula works the reverse way.

not({Detail.HoldBack} <> 0)

when the field is set to 1 it displays the section and when teh fiel is set to 0 it doed not display the section.

I want the section to display when the field is set to 0 and to not display when the field is set to 1.

Thanks,
junction123
 
does the field have a numeric zero or is it null?

did you perform null check?

isNulL({Table.Field}) OR TRIM(totext({Table.Field}))=""


If your data is null, it will stop processing the formula if you didn't specify what is to occur with nulls.
 
The field is a Number. Yes it can be blank(null).

I will try your suggestion .

Thanks
junction123
 

I tried the below but it did not work.

not(isNulL({Detail.HoldBack}) OR TRIM(totext({Detail.HoldBack}))="")

One more thing. I am running the report from another application after modifying the report formula. The application has a user defined function for the fields

Holdback, xyzholdback and interest. The values are blank. I set the value to 0 and 1 while testing.

With the above formula, the report shows the section for double line when thevalue is left blank, I tested this case.

But when I set the value to 0 or 1, I still see the double line. The report should not show the sectuion containing the double line. Is the formula correct or do I need to suppress blank section?

Thanks,
junction123


 
I also tried modifying the formula as below to accomodate all three fields. When Is set one field value , holdback, the other two values Interest adn xyzholdback automatically get set to the same value as holdback.


not(isNulL({Detail.HoldBack}) OR TRIM(totext({Detail.HoldBack}))="") AND
not(isNulL({Detail.LehmanHoldBack}) OR TRIM(totext({Detail.LehmanHoldBack}))="") AND
not(isNulL({Detail.Interest}) OR TRIM(totext({Detail.Interest}))="")



Thanks,
junction123
 
The conditional formula to suppress the section with the double line still does not work.

Not sure what else I need to add.

Thanks again for your help.
junction123
 
Don't check the box for section suppression--just use the conditional formula area and then try:

(
not isnull({Detail.HoldBack}) and
{Detail.HoldBack} = 1
) or
(
not isNull({Detail.LehmanHoldBack}) and
{Detail.LehmanHoldBack} = 1
) or
(
not isNull({Detail.Interest}) and
{Detail.Interest} = 1
)

-LB
 
Thanks.

I tried the above but it still does nto work when the values are left blank.

I also modifying the formula as below:

(
not isnull({Detail.HoldBack}) and
{Detail.HoldBack} >= 0
) or
(
not isNull({Detail.LehmanHoldBack}) and
{Detail.LehmanHoldBack} >= 0
) or
(
not isNull({Detail.Interest}) and
{Detail.Interest} >= 0
)

I still do not see the double line when the values are blank. The goal is to show the double line when the values are not set and left blank.

Thanks for your help.

junction123
 
I can't see why LBass formula does not work but you could try implicitly altering the field values e.g.

Code:
WhilePrintingRecords;
Local NumberVar HoldBack := If IsNull({Detail.HoldBack})  Then 0 Else ({Detail.HoldBack});
Local NumberVar HoldBack := If IsNull({Detail.HoldBack})  Then 0 Else ({Detail.HoldBack});

Gary Parker
MIS Data Analyst
Manchester, England
 
I also tried checking just for one column value as I set just one field value, holdbacka dn the otehr two get auto populated with the same values. I still do not see the section.

Appears the formula works the same way for both cases?

Case 1) field values are set then do not show the section
Case 2) field values are not set then show the section.

Thanks
junction123
 
pressed the wrong button there :

Code:
WhilePrintingRecords;
Local NumberVar HoldBack := If IsNull({Detail.HoldBack})  Then 0 Else {Detail.HoldBack};
Local NumberVar LehmanHoldBack := If IsNull({Detail.LehmanHoldBack}) Then 0 Else {Detail.LehmanHoldBack};
Local NumberVar HoldBack := If IsNull({Detail.Interest})  Then 0 Else {Detail.Interest};

Holdback = 1 or LehmanHoldBack = 1 or Interest = 1

If this doesn't work then I suspect there is something you haven't explained in your setup

HTH


Gary Parker
MIS Data Analyst
Manchester, England
 
The field types are numeric. The values can be 0, 1,2 and so on.

I get an error in the formula saying:

"The formula result must be boolean"

Thanks for your help
junction123
 
forgot to change a variable name

Code:
WhilePrintingRecords;
Local NumberVar HoldBack := If IsNull({Detail.HoldBack})  Then 0 Else {Detail.HoldBack};
Local NumberVar LehmanHoldBack := If IsNull({Detail.LehmanHoldBack}) Then 0 Else {Detail.LehmanHoldBack};
Local NumberVar Interest := If IsNull({Detail.Interest})  Then 0 Else {Detail.Interest};

Holdback = 1 or LehmanHoldBack = 1 or Interest = 1

what do you want to happen if any of the values equal 2

Gary Parker
MIS Data Analyst
Manchester, England
 
The section should not be displayed if any of the values are set. The data type is number. So it could be 0,1 2 whatever.

When the user does not set the field/s then the section should be displayed witht the double line.

Thanks again for your help.
junction123
 
Ok so if we look at just one of the fields are you saying

Value = NULL (Display)
Value = 0 (Display)
Value >= 1 (Suppress)

if so then just change the last part of my formula to

Holdback >= 1 or LehmanHoldBack >= 1 or Interest >= 1



Gary Parker
MIS Data Analyst
Manchester, England
 
I get the same error. The data type is number but is the formula possibly expecting a boolean result?

Thanks
junction123
 
my formula does return a boolean result.

please cut and past your formula exactly on to here

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top