[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

Changing report header while printing subreport

I have a report with a subreport.  On the main report I have a title that prints in the page header section.  When the subreport is printing, I want to change the title that is printing in the main report page header section.  How can I do this?

I am very new to Crystal Reports and have read some old questions that explained how to do this but it was over my head.  I imagine this isn't all that difficult but a step-by-step answer is probably what I need.

I am using CR9.

Thanks,
Chris
0
chlade
Asked:
chlade
  • 3
  • 2
  • 2
2 Solutions
 
mlmccCommented:
Try this

Create several formulas

In the main report header
Name - InitVars
Formula -
shared stringvar PageTitle := "Main Report";

In the Page Header
Name - DispPageTitle
Formula -
shared stringvar PageTitle;
PageTitle

In the subreport report header
Name - SubInitVars
Formula -
shared stringvar PageTitle := "Sub Report";

In the subreport report footer
Name - ResetVars
Formula -
shared stringvar PageTitle := "Main Report";

Obviously put the appropriate title in where they are set.

The idea is to share information with the subreport through variables.
When the report runs it will set the title to the main report then when the subreport starts it will set the title to sub report then reset it when complete.

mlmcc
0
 
frodomanCommented:
I agree with the concept mlmcc mentioned, but I'd advocate a different approach:

On your main report create 2 page headers (A & B).  PHa would be for your main report and PHb for your subreport.

Now for formulas:

In main report header:
shared numberVar IsSubPrinting := 0;

In subreport report header:
shared numberVar IsSubPrinting := 1;

In subreport report footer:
shared numberVar IsSubPrinting := 0;


Now simply use the Section Expert and conditionally suppress Page Header A when shared numberVar IsSubPrinting = 1 and suppress Page Header B when it's = 0.

The end result is much like the previous suggestion.  The advantage of this approach is that you can completely modify the page headers to show whatever information you want and format or move fields as desired - you aren't limited to just changing the text displayed.

HTH

frodoman
0
 
chladeAuthor Commented:
Ok, this is strange.  I have the first method working with one problem.  My report is 32 pages long.  Each subreport happens to be 16 pages.  However, instead of the subreport title starting on page 17 (where the subreport data starts), it starts on page 19.

Any ideas why?  This has me stumped.
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
frodomanCommented:
My guess is that the page header is large (height-wise).  If you followed mlmcc's instructions exactly then your variable doesn't change until the subreport header is printed, which is after the page header on that page is printed.  If the page header occupies enough space that could push it back.

There is actually a flaw in both of our suggestions.  You might want to create a section in your main report above your subreport.  In that section put the formula that is currently in the subreport header.  This will force the change before the subreport begins - otherwise the page header may print before the subreport header formula is evaluated and that would be a 1-page delay before it appeared correctly.

frodoman
0
 
chladeAuthor Commented:
Thanks guys.  Frodoman, that was all it took to clean up that problem.  

I didn't notice any obvious problems with the size of the page headers or anything else that would cause it to take 2 extra pages before kicking in.  But, regardless, putting the formula to switch it to the subreport heading just prior to calling the subreport fixed the problem.
0
 
frodomanCommented:
Glad to help.
0
 
mlmccCommented:
Glad i could help

mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now