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

Pass value from subreport

Status
Not open for further replies.

Jimgarry

MIS
May 16, 2000
112
Thanks in advance,

I am new to Crystal, I want to pass a number from a subreport to my main report. I want to be able to check the number coming over to see if it is greater then zero If it is then I want use the Detail line in the main report if it is zero I want to skip the detail line in the main report.

any suggestions?

I can get a sub report to bring a number over to the report but I do not know how to put that number into a varable on the main report so I can check its value

Thanks again
Jim Garry
 
If you use a shared variable you will be able to control that variable's value in the main report. Search for 'variables,scopes' under Crystal Help.
 
ok...create 2 sections to your detail section.....In the first section you will place your subreport...

if you are not displaying anything from the subreport, then suppress all sections of the subreport and in the main report make the subreport as small as possible and remove the borders to the field and snug up the lower section border to make the section as small as possible.

Now you will use a shared variable

In the subreport you will initialize it to zero in the sub report Report header

@initialize
Shared numberVar Value := 0;

Somewhere in the subreport this value is assigned

@Calc

WhilePrintingRecords;
Shared numberVar Value;
( *** add in the rest of the formula ***)

Value := (some field or calculation);

Now in the Main report Detail (B) section In the Section expert for the Conditional Suppress put the following formula

WhilePrintingRecords;
Shared numberVar Value;

Value = 0; // note negative values will show detail

In the Detail (b) you would arrange the fields normally and have one formula to display the value

@displayValue
WhilePrintingRecords;
Shared numberVar Value;

Value;


The only thing I am nervous about is your definition of Zero for value....I hope you don't mean that there are no records in the subreport...because this requires a slightly different approach.

Otherwise this will work...the reason for the 2 sections for the Detail is theat this garuantees the subreport runs first so you get the proper "value"





Jim Broadbent
 
Thanks for the information. I will try both of them. I find the help in Crystal not to work like I'm use to. I can't search in my systm's help like I think I should.

Both suggestions sound good I will try them

Thanks agin
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top