Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameters to subreport 2

Status
Not open for further replies.

e11a

IS-IT--Management
Jan 3, 2003
30
GB
Hello.

I have a main report with "from date" and "to date" parameters and would like to pass these dates to the subreport. At the moment I've created the same parameters in the subreport but would prefer not to enter the dates twice.

Is there any way of passing the parameters from the main to the subreport?

I've tried changing the links and passing the parameters to formulae but nothing seems to work. Am I being stupid and missing something obvious?

Thanks,

E.
 
hmmm...do you want the subreport to generate data over the complete range from - "from date" and "to date" - for every date encountered in the main report??

or do you wish to just generate a subreport for a given date based on the Main report?...simple linking to the date would do in this case. You cannot link on parameters I don't think...or a report formula which just has a parameter in it

However you might be able to fool Crystal by linking on a formula like this

@LinkToDate
WhilePrintingRecords;
if 1 = 1 then
{?Parameter ToDate}
else
(table.date};

Now the value of TableDate is linkable but the formula never uses it...this may fool Crystal into accepting it ...a similar formula for FromDate may also work




Jim Broadbent
 
ella,

I am using Crystal vers 8.5. When you select a parameter field to link by, Crystal places in the "Subreport Parameter Field" box a field name that begins with "?Pm-". This will not link to your parameter field in your subreport. Click the "drop-down" button in the Subreport Parameter Field box, then use the tiny down arrow to scroll down and select the correct parameter field of your subreport. This sould link your parameter fields correctly and not prompt for the subreport parameters.

Good Luck.

MrBillSc
 
You don't need parameters in the subreport, just join to the field, and then go into the record selection formula in the subreport and manually adjust it to say >= and <=.

I do this because I find that having these suprefluous parms in Crystal Enterprise and other external code can be confusing.

-k
 
SV - it all depends on how the subreport is being used.

It seems like she wants it to be like an in-place subreport without links but with parameters the same as the ToDate and FromDate to give a full range of a data set of the Main report

Not a subset of data based on a particular date in the main report....

If she wants it like an unlinked in-place subreport then usually separate parameters should be entered...I was kinda curious if my attempt at fooling Crystal would have prevented the necessity of entering the same dates twice

Jim Broadbent
 
If this:

&quot;but with parameters the same as the ToDate and FromDate&quot;

means the same as the ToDate and FromDate in the main report, that was exactly my point.

Perhaps you misunderstand, Jim. I meant link the parameter in the main report to the date field in the sub, and adjust the record selection formula appropriately.

It does what you mention, and eliminates some of the messiness that Crystal creates if you have redundant parameters joined to each other.

Note in Crystal Enterprise that subreport parameters will show up even if they're linked, you have to explicitly make sure that these are not enabled, or you're double prompted.

There are also issues with VB calling reports. What you suggest should work, as will what I suggest, the difference being that you don't have potential for redundant parms in my solution.

-k
 
If you're using one parameter with Range Values then try this:

Create two formulas (1)start date and (2)end date.

@Start Date
minimum({?Date parameter})

@End Date
maximum({?Date parameter})

Then link these two formulas to your subreport. The same date range in the main report will be used in your subreport.

If you're using two separate parameters for the From Date and To Date then directly link them to the subreport.
 
Thanks everyone for your help.

I've had another look at the report and managed to get it working using rrg's suggestion :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top