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

Conditionally Hiding Header Text Object

Status
Not open for further replies.

rkgrp

Programmer
Oct 29, 2003
15
US
Hi All,

Using Crystal Report Version 8.5.0.217.

I have created a Crystal Report with 3 groups. I have two text object
for a one field. Depends upon number of rows in detail band I want to
hide one text obj. ie. If detail band row count = 1 hide 1st text,
else (>1) hide 2nd text.

I have created three formula fields:
Formula 1: @Reset --> Placed on Header 1 Band
Script
------
WhilePrintingRecords;
booleanVar disp_flg := true;
numberVar Rec_Cnt := 0;

Formula 2: @Detail_Count --> Placed on Detail Band
Script
------
WhilePrintingRecords;
booleanVar disp_flg;
numberVar Rec_Cnt;
Rec_Cnt := Rec_Cnt + 1;
if Rec_Cnt > 1 then
disp_flg := true
else
disp_flg := false;

Formula 3: @Disp_Count
Script
------
WhilePrintingRecords;
booleanVar disp_flg;

Added following two conditional format on suppress of text obj:
text_obj_1: --> On Header 1 Band
Script
------
evaluateafter({@Disp_Count});
if {@Disp_Count} then
false
else
true;

text_obj_2: --> On Header 1 Band
Script
------
evaluateafter({@Disp_Count});
if {@Disp_Count} then
true
else
false;

It works fine when detail record count = 1, displays text_obj_2 in
same group header.
If record count > 1 for group # say: 3rd group, system still displays
text_obj_2 in 3rd group. But 4th group header gets text_obj_1,
eventhoug 4th group record count = 1.

I was trying to work around by placing those two text objects on
Footer 1 Band. It works perfect. I believe text object's formula being
evaluated as soon as 1st row printed in detail band.

Crystal Guru's, is there any work around keeping those two text
objects on Header 1 band.

Thanks in Advance
 
Try using the count function for your detail. The formulas aren't being evaluated until *after* you are past the header. That is the reason that the next group gets the values from the previous group.

Something like count({somedetailfield},{groupedonfield})

so if you want text_obj_1 in the group header to be suppressed if there is only one detail, in the conditional suppression formula:

count({somedetailfield},{groupedonfield})= 1

Hope this helps.

Lisa


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top