Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: DBlank - passing variables from main to subreport Post Reply Post New Topic
Author Message
jknockler
Newbie
Newbie


Joined: 05 Mar 2009
Location: Ireland
Online Status: Offline
Posts: 32
Quote jknockler Replybullet Topic: DBlank - passing variables from main to subreport
     Posted: 28 May 2009 at 7:40am
Hi,
 
If you are DBlank, hi. With regards to the problem I was having with displaying a graph from two tables, and you replied to my query and gave me a very comprehensive explanation and suggestion for what was happening and what to do, I owe you a big big thank you as it has worked a treat. So again I thank you very very much for that.
 
However...... dahn...dahn..DAHN..... Another problem has occured whereby I have placed my chart on a subreport and put the subreport iin the main report.
 
The subreport has every value, formula, select criteria, etc as the main report.
 
In the main report I have a 'start' and 'end' date as parameters.
However, 4 parameters are displayed as the subreport also has a 'start' and 'end' date.
 
I was wondering if there is a way in which I can delete the date parameters from the subreport and pass the date values from the main report to the subreport. (which is what i suspect is how this is done)
 
If this is the way this is done, would you be so kind as to give me an example or two on how to pass parameters from a main report to a subreport? as ive never done this before.
 
Thanks again.
 
 
J. 
J
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 May 2009 at 9:31am
Hi J. Glad you got it working.
So I think I understand your issue here. When you run the main reoport it is asking for 4 dates to be entered, 2 for the main report and 2 for the subreport, although these are really the exact same dates betweeen the two reports. You are looking for a way to pass the original begin and end date parameters from the main report to the sub report while having the user enter them only once. Correct?
 
I have not done this myself but the question seems to come up a lot on the forum.
Debmac posted this link answering a similar question that should do what need although I have not personally tested the answer.
 
Give it a shot and let us know if it works
 
 
 
IP IP Logged
jknockler
Newbie
Newbie


Joined: 05 Mar 2009
Location: Ireland
Online Status: Offline
Posts: 32
Quote jknockler Replybullet Posted: 28 May 2009 at 9:36am

Hi DBlank. Thanks for that. I'll look it over and let ya know how it goes.

 

Thanks again.

 

J

J
IP IP Logged
Takesen
Senior Member
Senior Member


Joined: 29 Dec 2008
Location: United States
Online Status: Offline
Posts: 143
Quote Takesen Replybullet Posted: 28 May 2009 at 5:04pm
If i may?
 
I've been having to do a lot of work with subreports lately...
You can pass the Start and end date from the main to your subreports
via the linking options...
 
But before you do that, are you using any shared variables to pass data from your subreport to your main report? If so, i do not think this will work for you. If you're not passing values from your subreport to your main, then this should work beautifully...
 
Go ahead and enter design view, and right mouse click on your Subreport.
 
Go to Change Subreport Link... Now,
you sould have a Subreport Links box. The left are fields from your main report you can move to the box on the right. Go ahead and move over the, {?StartDate} and {?EndDate} (or what you have them named as...).
 
Go ahead and highlight one of them (either one is fine you're going to be doing this to both of them...)
 
There's a ?Start field link underneath these two boxes you were using, on the left drop down should say ?Pm-?StartDate. and the right is what you're going to be linking this parameter to. In this case the timestamp.
 
Now do the exact same thing for the ?EndDate.
 
Now, From here, right mouse click on the subreport again, go to edit.
Then go to your Select Expert in your Timestamp criteria, it should now show up in a formula form. like:
 
{table1.timestamp} in [{?StartDate} to {?EndDate}]
{table1.timestamp} = {?Pm-StartDate}
{table1.timestamp} = {?Pm-EndDate}
 
What you're going to want to do, is just Cut the {?Pm-StartDate}
and replace {?StartDate} with {?Pm-StartDate} and the same thing with the EndDates.
 
Once you're done, your Select Expert Formula for this should look like:
 
{table1.timestamp} in [{?Pm-StartDate} to {?Pm-EndDate}]
 
 
 
Hope this helps!
If I was unclear, please let me know and i'll try to clear it up.
 
-Takesen
 
IP IP Logged
jknockler
Newbie
Newbie


Joined: 05 Mar 2009
Location: Ireland
Online Status: Offline
Posts: 32
Quote jknockler Replybullet Posted: 02 Jun 2009 at 2:53am
Thank you DBlank & takesen for all your help. The main & sub reports are linking perfectly. Thanks again.
 
J
J
IP IP Logged
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