Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Get field from subreport Post Reply Post New Topic
Author Message
w00tNL
Newbie
Newbie


Joined: 28 Feb 2008
Location: Netherlands
Online Status: Offline
Posts: 6
Quote w00tNL Replybullet Topic: Get field from subreport
    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!


Edited by w00tNL - 06 Mar 2008 at 2:51am
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet 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.
IP IP Logged
w00tNL
Newbie
Newbie


Joined: 28 Feb 2008
Location: Netherlands
Online Status: Offline
Posts: 6
Quote w00tNL Replybullet 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
IP IP Logged
louisville2k10
Groupie
Groupie
Avatar

Joined: 13 Sep 2010
Location: United States
Online Status: Offline
Posts: 45
Quote louisville2k10 Replybullet 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!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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


Edited by DBlank - 17 Feb 2011 at 5:33am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.030 seconds.