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!

How share variable between subreport and main report.

Status
Not open for further replies.

alexbelovtt

Programmer
Nov 15, 2005
51
US
I use Crystal 11 and visual basic.
I have main report that contains several subreports.
Some of subreports have section where I do display special characters. If that character displayed I do need display explanation on main report Page footer:
Main report:
Subreport 1
Subreport 2
Subreport 3 (with special characters)
Subreport 4
Subreport 5.
Main report page footer:
Here I do need display explanation of special characters if those characters have be displays in page of Subreport 3
I do need:
1. Reset variable in main report Page Header to 0
2. Change variable in Subreport 3 if special character printed to be more than 0
3. Read value of variable in main report page footer to display or not explanation.
Whatever I try, changes to variable are not visible in between main report and subreports.

To accomplish that I create formulas:

1. Page header of main report
Code:
WhilePrintingRecords;
Shared NumberVar LineCount:=0;

2. In section of subreport 3, where those characters may be printed:
Code:
Shared NumberVar LineCount;
IF {Required_Flag} = 'Y' THEN  
LineCount := LineCount + 1;
LineCount
3. In page footer of main report I try to read that variable:
Code:
whileprintingrecords;
Shared NumberVar LineCount;
LineCount := LineCount;
Sure I do something wrong.
Any suggestion will be helpful.
Thank you.
Alex.
 
The main report section that displays the shared variable must be BELOW the section where the subreport is.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thank you.
If I put last formula to the next section after subreport and that section will be suppressed, could I read that variable in page footer using same code?
Alex
 
Thank you, Ido.
I’ll test that carefully over weekend and let you know.
What also confusing me – when I’m inserting subreports by right click on section and choose insert – subreports, subreport doesn’t have Page header and footer.
Do you know any way to make subreports with page footer and header?
I just test all three ways – form wizard, form existing report and form designer.
All result is same - subreports don’t have page header and footer.
If I can insert subreports with page footer and header, then I do not need all those formulas.
I try to play with add section below on subreport, but that only inserts detail or report footer a.
 
subreports never have page headers/footers. You can "fake it" by inserting a level-1 group that is based on a constant formula value. Set the group sections to repeat on each page and use them as if they are page headers/footers.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top