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

Change page footer dynamically depends of page context. 1

Status
Not open for further replies.

alexbelovtt

Programmer
Nov 15, 2005
51
US
I have report with 12 subreports.
Depends of what data field of subreports or part of subbreports is displaying on to the page, I need change page footer.
If subreports has only one record or record that define footer value is last one I can use formula for section and suppress or show.
But if record in to the middle, I can’t catch when that happened.
Does Crystal have formula to loop through each record on page and exit loop if condition reached?
May be possible to set global variable for page and change it only once when condition is meets?
To make my question simple I want to know:
Is certain field displays on to the current page;
Is the value of that field meets my criteria at least ones.
Sorry if that question is newbie…
Than I think I can add three page footers and suppress or not.
 
You can do line counts, using the general method:

Code:
//In the page header
WhilePrintingRecords;
NumberVar LineCount :=0;

In a one-line setion
WhilePrintingRecords;
NumberVar LineCount := LineCount + 1;

In a two-line setion
WhilePrintingRecords;
NumberVar LineCount := LineCount + 2;

Then test line-count against a summary count.  Start a new page if there isn't room

That doesn't directly fix your problem, but might be adaptable.

Remember also that shared variables will return values from subreports, useable in the section below.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thank you, Williams.
Will test right now.
Does that means I can declare global variables in main report (container for subreports) header and change their value in subreports?
And than read variables back in main report page footer?
If that is true I can solve my problem.
 
Global variables are not the same as shared variables.

For a date, put a formula field in the subreport like
Code:
Shared dateVar 
V_Today := {LoadStatus.LastDLoad}
To access it in the main report, create another formula field with
Code:
Shared dateVar 
V_Today := V_Today

If it was a currency value, you'd do it differently, e.g.
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Remember that they can only be used in the main-report section below the section that calls the subreport.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thank you Williams for good lesson
That is work on level of main report.
But if I try to use that solution on level of subreport I can’t get result.
Solution is simple:
I need variable on page level.
That variable must be change in one section and than based on that variable I want suppress or not page footer.
I add formula field to report.
I add code to formula:

stringvar QuestRequred;
If {SupplementalQuestionByVersion.Required_Flag}='Y' then
QuestRequred='Y'
In simple word – whatever field has value ‘N’ I do not care, but if one or more time field has value ‘Y’ I want to set QuestRequred to ‘Y’ and do not change.
On page footer I try to read QuestRequred, but it’s not visible.
What I’m doing wrong?
Thank you.
Alex
 
Make it Shared stringvar QuestRequred. That's necessary for it to pass from the subreport to the main report.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Williams,
That is done for subreport and main report.
Sorry for not clear question.
Now I try to repeat same for page footer of subreport.
Sure that is report footer, marked as “Print on bottom of page”.
Must be stringvar to be shared? I do not want it to be visible on next page if fields value will be not changed.
Or, may be I must reset that variable on beginning of each page?
In real life we can look at that subreport as just report.
Section Detail2 may have fields value ‘N’ and ‘Y’
I need to capture if any ‘Y’ happened and than suppress page (report in case of subreport) footer.
If I use current formula I get ‘Y’ only if last value of field is ‘Y’.
I want to have ‘Y’ if any field value is ‘Y’ otherwise an empty string will be OK.
Alex
 
Any variable can be shared, including boolians.

The best way to learn Crystal is to use [Save As] to get a test version and then experiment with it to see how things work in practice.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top