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!

Shared variable used to suppress section

Status
Not open for further replies.

ProfessorSnail

Technical User
Oct 11, 2010
10
GB
Hi,

I have been trying to pass a variable from a series of subreports to the main report. The variables are then used to suppress a section.

I've set up the formula to define the variable in each of the subreport (X Y Z for separate subreport). The subreports are placed in separate Group Headings (GH1a, GH1b etc.)

whileprintingrecords;

Shared NumberVar X:=

if isnull({Table.Field})
then 0
Else 1;

The formula is placed in the subreport footer. This part seems to work ok and displays '1' or '0' depending on whether there is data in the subreport.

I then want to add together the variable on the main report. The formula I have used is as follows:

whileprintingrecords;
Shared NumberVar X + Shared NumberVar Y + Shared NumberVar Y

I've placed this formula in within the same group but as a separate section (after all the subreports).

This part does not seem to work. I want to use the result to determine whether the group header section is suppressed i.e.

Suppress if:

{@formular above}=0

What am I doing wrong? Or is there a better way to suppress a section? The problem is not having any of the subreport data available on the main report.

Thanks,

Sam
 
I managed to solve my own problem by including the header text in each of the subreports and then passing the variables from one subreport to the next. The variables are then used to suppress the subreport header accordingly.
 
How did you include the header text? Did you uncheck "suppress printing if no records" in file->report options for the subreport?

If you are passing shared variables, you cannot suppress the subreport directly or the section it is located in in the main report. What you can do is suppress all sections within the subreport, format the sub to "suppress blank subreport", remove the borders, and format the section that contains the sub to "suppress blank section."

-LB

 
The report is a single record report which uses lots of group headers (all under the same group (ID number)).

Because I am only passing a '0' or '1', it does not seem to matter whether the sub report is suppressed i.e. the variable is '0' anyway.

I've used conventional methods of suppressing sections throughout the report but this particular sections was proving tricky because it relied on data being present in at least one of the subreport.

Originally I had the heading text for the group of subreports in the main report but could not suppress it based on a variable because the section was above. By duplicating the section heading in the subreports and suppressing based on the previous subreport (if a '1' is returned) I've got round the problem.

Thanks for your response.

Sam
 
Just to clarify for any readers, if you suppress the subreport object, it guarantees that any shared variables CANNOT be passed from that subreport to the main report, and those values will be zero.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top