Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Share Date Range Parameters Post Reply Post New Topic
Author Message
NeilHunter
Newbie
Newbie


Joined: 15 Jul 2013
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote NeilHunter Replybullet Topic: Share Date Range Parameters
     Posted: 21 Aug 2013 at 4:45am
Hi Everyone

I have a report with a date range parameter that works fine although I need to use the same date range for data on a sub report.

I found and tried following the steps from the link below but I receive a blank sub report.

http://bofocus.com/how-to-pass-a-date-range-to-a-subreport-using-a-parameter/

Any help anyone can give me would be greatly appreciated.

Many thanks

Neil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Aug 2013 at 4:50am
I don't know, the first thought that comes to mind is to create a couple of simple formulas...I am assuming that the parameter is an array of start and stop values, because if the report uses 2 different parameters, you would just link them to separately to the subreport.

so on the assumption that you are using something like:
{table.field} in {?parameter}...or something like that syntax, I would create formulas like:
{?parameter}[0]//would be the first value...probably the start
different formula
{?parameter}[1]//the ending value???

then use these formulas in the linking from the report to the subreport.

I could be off my rocker, but it is what I would try first.

HTH
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 21 Aug 2013 at 5:16am
Hi

I think this can be achived using below steps :

-Create two formulas for start date and end date

Start date
Minimum({daterangeParameter})

End Date

Maximum({daterange Parameter})

Now you pass this values to sub report and filter your sub report based on start date and end date
Thanks,
Sastry
IP IP Logged
NeilHunter
Newbie
Newbie


Joined: 15 Jul 2013
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote NeilHunter Replybullet Posted: 21 Aug 2013 at 5:17am
Hi and thanks for your prompt response.

Sorry but I'm not quite following you and not used a formula like you suggest before.

The formula that I am using is:

{@DateLink} in {?Pm-?Date} to {?Pm-?Date}

The DateLink formula is:

date({Command.Action Date})

The Parameter in the main report is a basic static parameter of the 'Command.Action Date' field with Ranges allowed.

Thanks for your help.

Neil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Aug 2013 at 5:34am
OK, since the main report allows ranges, Crystal really stores values in an array named the same as the parameter.
By default, the first array value is used, to the formula: {@DateLink} in {?Pm-?Date} to {?Pm-?Date} doesn't work except for records that match the value of {?Pm-?Date}.

I would still split the array into 2 different values using the [x] notation...as this will access each part of the range parameter.

I would also change the formula in the subreport to be something like {@DateLink} in {@start} to {@end} and link {@start} parameter to the equivalent start formula, and similarly for the end parameter and formula.

Hopefully this is clearer
IP IP Logged
NeilHunter
Newbie
Newbie


Joined: 15 Jul 2013
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote NeilHunter Replybullet Posted: 21 Aug 2013 at 5:34am
Thank you for your response but I think I must be doing something daft as when I pass the min and max values to the sub report they are blank.

the Min and Max formulas work on the main report and I use the formula below to pass them to the sub report:

shared datetimevar StartDateShare;

StartDateShare := {@Start Date}

Ten on the sub report I retrieve them using:

shared datetimevar EndDateShare;

EndDateShare

Also, when I looked at creating a parameter using the formula fields they were not available from the list of report fields.

Sorry if I'm missing something simple and thank for taking the time to help with this.

Neil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Aug 2013 at 5:40am
I am assuming that you pass both start and the end dates and the example is just a typo basically...as the variable names don't align, but the logic is correct.

Sorry, I didn't think about the formulas not being available...

well the next version of the solution is to pass the 'entire' parameter...and we'll see how that goes...

in the main report:
shared datetimevar array par := {?Pm-?Date};

then in the subreport:
shared datetimevar array par;

now use par as you would have used {?Pm-?Date} in the main report.

it's worth a try...


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Aug 2013 at 7:44am
You may be over complicating the process.
As sastry recommends create two formula fields in the main report
//Start date
Minimum({daterangeParameter})
//End Date
Maximum({daterange Parameter})
 
Now right click on the subreport
select "change subreport links"
select the available field of @ start date
there will now be a ?Pm-@startdate link
repeat for @ end Date field
Hit OK
edit the subreport
in the sub report you now have 2 parameters
use these in the sub reports select expert to limit your data...


Edited by DBlank - 21 Aug 2013 at 7:45am
IP IP Logged
NeilHunter
Newbie
Newbie


Joined: 15 Jul 2013
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote NeilHunter Replybullet Posted: 21 Aug 2013 at 10:06pm
Thank you all for your help. I have managed to get it working using DBlank's steps.

Thanks again.
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