Print Page | Close Window

Cannot keep persistent variable value

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9447
Printed Date: 31 Mar 2025 at 12:23am


Topic: Cannot keep persistent variable value
Posted By: LuisSantos
Subject: Cannot keep persistent variable value
Date Posted: 22 Mar 2010 at 2:40am
I have a header and detail table.
Based on conditions, I may or may not print detail lines. Therefore I need to know when a detail line was printed in order to print related header line. Report looks like this:
 
GF2 - detail line 1a (printed)
GF2 - detail line 1b (printed)
GF1 - detail header 1 (printed)
 
GF2 - detail line 2a (no print)
GF1 - detail header 2 (no print due to no GF2)  
 
GF2 - detail line 3a (printed)
GF2 - detail line 3b (no print)
GF1 - detail header 3 (header line should print due to line 3a printed, but evaluation of controlling flag gets overriden at GF2 time)  
...
 
I tried to overcome problem by using a shared variables (in GF2) hoping that second time around "Shared StringVar ph" would retain it's original value:
 
// set flag to print header data
Shared StringVar ph;
//
// if not yet set to print from another task
if (ph = "N" or ph = "") and
({?Report Details} = "No Due Date" and s = "No Due Date") or
({?Report Details} = "Schedule" and s = "Due Now") or
({?Report Details} = "Tasks Closed" and s = "Task Closed") or
(
({?Report Details} = "Tasks Closed" and s = "Task Closed" and
   ({aualdocs.fmt_acc} <> Previous({aualdocs.fmt_acc}) or
    ({aualdocs.fmt_acc} = Previous({aualdocs.fmt_acc}) and {aualtask.rea_cde} <> Previous({aualtask.rea_cde}))))) or
({?Report Details} = "Overdue" and s = "Overdue")
 then ph := "Y"
 else ph := "N";
// set variable status
ph;  
 
Any suggestions will be much appreciated.



Replies:
Posted By: DBlank
Date Posted: 22 Mar 2010 at 4:17am

Hard to tell as I do not understand you design logic but basically it loks like you have conditions for each GF2 to print or not, from there you want the GF1 to print if any GF2 row also prints.

Logically then you can so this by usings a SUM.  For your GF2 logic apply a formula for "if print condition met then 1 else 0"
Now SUM that at GF1 level and condtionally suppress it where that Summary=0.


Posted By: LuisSantos
Date Posted: 22 Mar 2010 at 2:40pm
DBlank,
 
You were spot on !!
I tried so many things I was getting tangled up, so I said to myself "I need a fresh look at this".
 
Thank you very much for your reply. Much appreciated.
Luis



Print Page | Close Window