Print Page | Close Window

Get field from subreport

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2520
Printed Date: 01 May 2024 at 10:31pm


Topic: Get field from subreport
Posted By: w00tNL
Subject: Get field from subreport
Date Posted: 05 Mar 2008 at 7:44am
Hi,
 
I've got a small problem and I don't know how to solve it.
 
I have got four subreports in my main report at the moment. Now I have some sums in those subreports and I want to use those value's in a new subreport that makes a small overview.
 
I have the book "The Complete Reference" (I know, sorry I don't have the encyclopedia) they talk about variables, but I don't know how to implement them with subreports.
 
Could you push me in the right direction?
 
Thanks in advance!



Replies:
Posted By: jkwrpc
Date Posted: 05 Mar 2008 at 11:47am
To move values between main reports and subreports you can use shared variables.
 
This is from the CR help file.....
------------------
Shared BooleanVar Outstanding;
 
Declares a shared variable named Outstanding that can hold a TRUE or FALSE value. This variable would be available in both the main report and any subreports contained within the main report.
--------------------
Look under variables in the help file and you should be able to find the answers to your questions. The only trick will be is when to reset the value of the variable. The answer to that is in your overall report design.
 
Hope this is of some help.
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net


Posted By: w00tNL
Date Posted: 06 Mar 2008 at 1:29am
Hm, ok. Now I have this.
 
In the main report I have a new formula wich contains this:
Shared NumberVar totaal_order := 0;
Shared NumberVar totaal_inkopen := 0;
Shared NumberVar totaal_uren_kost := 0;
Shared NumberVar totaal_uren_bedrag := 0;
Shared NumberVar totaal_addkosten := 0;
Each of these are Sums in a subreport. Now if I go to a subreport, lets's say Order, and I paste the code in the existing formula wich makes:
Shared NumberVar totaal_order := Ceiling (({FOFFVOLG.OVAANTAL} * {FOFFVOLG.OVBEDRAG})-{FOFFVOLG.OVKORTING},0.01);
If I go to the preview window then it gives back the error:
A summary has been specified on a non-recurring field.
Details @bedrag-korting
Now bedrag-korting is the formula name in the subreport Order. Could you help me with this? Because I don't know what I'm doing wrong... Confused


Posted By: louisville2k10
Date Posted: 17 Feb 2011 at 4:33am
I too would love to know the answer to this. I'm struggling to figure out how to pass fields from subreports to its parent report.

-------------
Thanks for your help!


Posted By: DBlank
Date Posted: 17 Feb 2011 at 5:32am
in the subreport you are defining the value of the shared variable like so...
formula name = sr_totaalorder
Shared NumberVar totaal_order;
totaal_order:= (sum(table.number))
 
the blue is just an sample option for a value to set it to
 
Now in the main report you are just making the shared variable again setting it to this new value as this ....
formula name = mr_totaal_order
 
Shared NumberVar totaal_order;
totaal_order:=totaal_order
 
now you can use this returned value by referencing the formula field  of "mr_totaal_order"
Note that the subreport must be called in a section that is read before the section that you place the main report formula into for it to work
e.g.
RHa = subreport
RHb = placement of mr_totaal_order



Print Page | Close Window