Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: How to pass value from main report to sub report Post Reply Post New Topic
Author Message
madhugangaraju
Newbie
Newbie


Joined: 29 Mar 2010
Online Status: Offline
Posts: 13
Quote madhugangaraju Replybullet Topic: How to pass value from main report to sub report
    Posted: 31 Mar 2010 at 7:35pm
Hi All
iam designing a report which includes subreport every thing is fine but i have to display the grand total in subreport which includes the main report total field . So how i get the main report total in to the sub report
Thanks in advance
madhu
IP IP Logged
E-T-M
Newbie
Newbie


Joined: 29 Mar 2010
Location: Ukraine
Online Status: Offline
Posts: 16
Quote E-T-M Replybullet Posted: 31 Mar 2010 at 9:46pm
You have to use shared variables.

Declare a shared variable in a formula of your main report
e.g.
shared numbervar NAME := <YOUR FORMULA>


Now you can address this shared variable in your subreports' formulas.


Edited by E-T-M - 31 Mar 2010 at 9:50pm
IP IP Logged
madhugangaraju
Newbie
Newbie


Joined: 29 Mar 2010
Online Status: Offline
Posts: 13
Quote madhugangaraju Replybullet Posted: 31 Mar 2010 at 10:00pm
thanks for your reply
but how should i use this formula field in the subreport
thanks in advance
madhu
IP IP Logged
E-T-M
Newbie
Newbie


Joined: 29 Mar 2010
Location: Ukraine
Online Status: Offline
Posts: 16
Quote E-T-M Replybullet Posted: 01 Apr 2010 at 5:33am
Here's a detailed example:

1. In main report create a formula, name it, edit it with the formula editor as follows:
shared numbervar NAME := {table1.field1} + {table1.field2}
Save formula.
note that you should replace the name and type of variable and a formula with ones of your own


2. Now create a formula in your subreport, name it, edit it with the formula editor as follows:
Shared numbervar NAME;
NAME
Save formula.

3. Use formula created in step 2 in your report.

This way you will have a {table1.field1} + {table1.field2} result from main report transferred to your subreport.


Edited by E-T-M - 01 Apr 2010 at 10:37pm
IP IP Logged
madhugangaraju
Newbie
Newbie


Joined: 29 Mar 2010
Online Status: Offline
Posts: 13
Quote madhugangaraju Replybullet Posted: 01 Apr 2010 at 9:00pm
Thanks for your reply
i tried it but it is not working
In my subreport i created the formula field and just typed the 'NAME' which is the variable declared in main report and it is showing error
I tried in the following way
1.In Main Report I created a formula field 'TEST' and declare the following code like:

shared numbervar NAME:={DTM200QTY}


2.In sub report I Created a formula field 'TEST' and declare the following code like:

NAME //which is shared variable in main report


It is showing error then i change this formula in this way in the sub report

shared numbervar NAME:= NAME//variable from main report  i think so 

NAME-{DTM20QTY}//sub report total field

i place it in sub report it is showing only the sub report field value {DTM200QTY} but not the difference of the shared variable and the subreport field
how should i get this
madhu
IP IP Logged
E-T-M
Newbie
Newbie


Joined: 29 Mar 2010
Location: Ukraine
Online Status: Offline
Posts: 16
Quote E-T-M Replybullet Posted: 01 Apr 2010 at 10:35pm
OK
I've tested and it works
Main Report
Shared numbervar NAME := 45

Subreport
Shared numbervar NAME;
NAME + 50


Note that subreport is processed after the main report, so it's easier to pass values from main report to subreport. Vice versa is also possible but is more painful :)
IP IP Logged
madhugangaraju
Newbie
Newbie


Joined: 29 Mar 2010
Online Status: Offline
Posts: 13
Quote madhugangaraju Replybullet Posted: 01 Apr 2010 at 11:22pm
Thanks
Its working fine thanks a lot
and another issue iam facing how to fix the size of the detail section means
it is fixed for 12 records and if the 9 records are printed then also detail section should be in the same size
thanks in advance

Edited by madhugangaraju - 02 Apr 2010 at 12:18am
madhu
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.