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

Sub Report

Status
Not open for further replies.

papakula

Programmer
Aug 21, 2001
33
GB
Is it possible to send parameters from subreport
to main report.. I mean main report should not have
any parameters..
 
You can share data between a main report and subreports.

In CR7 the feature was "Shared" variables.
Shared numbervar myTotal := ... // something in the subreport

And back in the main report (or another subreport).
Shared numbervar MyTotal; // to get it back again.

Priot to CR7 you could use FetchNumberVar, and StoreNumbgervar functions - but they were a lot slower.



 
Thanks , can u be more detail.. I hd tried
to do this but its not clear to me
 
In order to pass values from the subreport to the main report in version 7.0 upwards you need to do the following:

Create a formula as follows and place it in the subreport.

whileprintingrecords;
shared numbervar test;
test:= (table.field) * (table.field)

test;

You can use the normal variable declarators.

In the main report, Create a formula in which you want to use the variable:

WhilePrintingRecords;
shared numbervar test;

test;

This will return the value. The variable can be used like any other field, ie it can be added to other numberfields etc and used in formulas as necessary.

you will need to be aware that the variable will need to be reset if groups etc are involved. The best way to do this (I find) is to creat the same groups in the subreport and the main report and reset the value in the subreport. You will also need to beware that the positioning of the formula calling the variable from the subreport to the main report will effect the output and can also effect the totals. You may need to play around with group headers and footers (and the whereabouts of any reset formulas in the main report) if your report is complicated.

If you need to pass a parameter value (ie - Crystal reports prompt) you need to create an exact copy of the prompt from the main report in the subreport and then link the 2 fields in the "subreport Links" in the main report.

If you need any further help, please let me know.

Kind regards,
Justine Binnall.
 
Thank U very much. Wt I am trying to do is I want
to send 2 dates as startdate and endate from
Sub report.. As U told in Sub report I hd
1. I hd created formula field SDate
whileprintingrecords;
shared datevar Edate1:={?EndDate};
Edate1;
2. Similary for EDate
3. I hd creatd 2 parameters for Sdate and Edate

4. I hd gone to main report and created a
formula field as MSdate
whileprintingrecords;
Shared datevar Sdate1;
Sdate1;
5. similary for end date..
6. Next what I hv to do..



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top