Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Passing parameter fields to Crystal XI subreport Post Reply Post New Topic
Author Message
TAH2
Newbie
Newbie
Avatar

Joined: 16 Mar 2010
Online Status: Offline
Posts: 23
Quote TAH2 Replybullet Topic: Passing parameter fields to Crystal XI subreport
     Posted: 18 Mar 2010 at 5:38am
I have a report that contains 2 subreports.  I need to obtain data in each subreport based on a date range.  The main report does not require this.  I created the parameter DateRange with type date and a variable also named DateRange with the following syntax. 
 
dateTimeVar start := minimum({?DateRange}) + iif(minimum({?DateRange}) = {?DateRange}, 0, 1);
dateTimeVar end := maximum({?DateRange}) - iif(maximum({?DateRange}) = {?DateRange}, 0, 1);
booleanVar lowerbound := totext(year(start), 0) <> "0";
booleanVar upperbound := totext(year(end), 0) <> "0";
stringVar txtstart := totext(start, "d MMM yyyy");
stringVar txtend := totext(end, "d MMM yyyy");
if not lowerbound then //no start
    "Up to " + txtend
else if not upperbound then //no end
    "After " + txtstart
else
    "Between " + txtstart + " and " + txtend;
 
Typically I set the date field in my table equal to the DateRange variable.  I cannot figure out how to pass the parameter DateRange or variable DateRange to my subreports and use it to filter records.  I keep getting data type errors.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Mar 2010 at 3:13am
you might try using a shared variables and then have your subreport just reference the shared variables...they wouldn't need to be parameters per se.  If your subreport connects directly to the database, then you could just use the shared variables in the data filter.
 
Hope this makes sense.
IP IP Logged
Yudi
Newbie
Newbie


Joined: 03 Aug 2009
Online Status: Offline
Posts: 13
Quote Yudi Replybullet Posted: 21 Mar 2010 at 3:19am
Hi TAH2
 
i'm sorry if i don't quite understand about your question. But if you want to obtain the data from subreport you have to use the shared variable. You have to declare a formula in subreport and also a formula in the main report. Both of those formulas must declare the same variable (name and data type) as shared.
 
For example, create a formula in subreport (i'm using basic syntax) :
shared DataToObtain as string
DataToObtain = "Data From Subreport"
Formula = DataToObtain
 
then, in the main report you have to declare another formula :
shared DataToObtain as string
Formula = DataToObtain
 
i have wrote a simple article containing the sample to use shared variable in my blog. Just open this following link :
 
 
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