Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Pass a subreport parameter fro the prior year Post Reply Post New Topic
Author Message
cfrey
Groupie
Groupie


Joined: 06 Feb 2008
Location: United States
Online Status: Offline
Posts: 55
Quote cfrey Replybullet Topic: Pass a subreport parameter fro the prior year
    Posted: 03 Mar 2010 at 9:25am
Hello,

The main report has a date range parameter. I would like to use this parameter to link to the subreport for the previous year.

For example:

Main report parameter is 1/1/10 to 2/28/10

I would like to select data from my subreport for 1/1 09 to 2/28/09.

I've tried
{field} >= dateadd("YYYY",-1, minimum({?Date Range})) and
{field} <= dateadd("YYYY",-1, maximum({?Date Range}))
but this does not select any records.

Thank you for your help
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Mar 2010 at 9:47am
Create 2 seperate formulas, one for your start as StartDate:
Dateadd('yyyy',-1,minimum({?Date Range}))
 
and one for your end as EndDate:
Dateadd('yyyy',-1,maximum({?Date Range}))
 
Right click on the subreport and select Change Sub report links.
Add @StartDate and @EndDate as new linking options.
In your SUbReport design you will now see 2 new params
In your select statment in the subreport add
{table.Date} in {?Pm-@StartDate} to {?Pm-@EndDate}
 


Edited by DBlank - 03 Mar 2010 at 9:47am
IP IP Logged
cfrey
Groupie
Groupie


Joined: 06 Feb 2008
Location: United States
Online Status: Offline
Posts: 55
Quote cfrey Replybullet Posted: 03 Mar 2010 at 11:54am
That worked. I did have trouble with the passed date parameter as it came though with time. I enclosed the parameter in date() and it worked great.

Thank you so much for your help.
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.031 seconds.