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 date range to subreport from parameter in main report?

Status
Not open for further replies.

huckfinn19

Programmer
May 16, 2003
90
CA
Hi, I'd like to pass my date range parameter to my subreports from a parameter field in my main report, that so they'd only gather appropriate data within date limits. The only way I've found is to use a formula like :

{@Get min}
minimum({? Date Limits})

Then I can link to the subreports and pass them the values, but when I do this, my subreports are not automatically run anymore when I refresh my subreport! So I have to double click them to see the data, and I'd really like them to be executed when I refresh my main report!

Is there any different way to pass the date range parameter?
Or is there a way to make my subreports to be automatically executed when I refresh my main report?

Thanks,

Simon
 
When you select the links, point at the date range parameter in the main report, and in the "Select Data in Subreport based on field" point at the date field.

Where you might get in trouble is if the subreport contains a datetime, and you've specified a date type parameter (instead of datetime).

If this is the case, you can either build a date range parameter in the subreport, and point the main report parameter to the subreport parameter, and then build a record seelction formula based on your subreport parameter.

Or build 2 formulas in the main report that create datetime fields from the min() and max() of the main report parameter, join each to the date field of interest in the subreport, and then edit the record selection formula to use >= and <= against the formulas.

-k
 
The type of paramete shouldn't affect the running of the subreports. Are you sure that you didn't accidentaly change these to &quot;on-demand&quot; subreports?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Nah, the On-Demand really wasn't selected... Here's what my problem was :
the problem was the way I was passing the parameters... I was using functions to convert the parameters, when I should have been using 2 identical parameters, one in the main report one in the sub and link them correctly...

So using a formula in the main report, and link it to the subreport and use it in the selection formula really isn't a good way to pass parameters...

thanks all!

Simon
 
Has anyone else see this behavior? I have linked to formula fields without getting this behavior, so I am puzzled. What version of CR are you using? Would you mind posting the formula?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
I'm using CR v8.5, but as I said, I am no longer using a formula...

Here's what I did :
- Set up date parameter field in main report
- Set up identical date parameter field in sub report
- Add the subreport in the main report
- right-click, choose Change Subreport Links
- Select your parameter in the main, and link it to the one in the subreport.

Now, everything works fine...

best of luck

SImon
 
Sorry, you missed my point. I would like to recreate the failure you experienced when linking to a formula. I don't get the same failure when linking to a formula.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Ok... What I did was create 2 formulas in my main report :
{@GetStartDate}
{@GetEndDate}

which would return a number representing standard GMT time of the maximum{?Date Boundaries} and minimum{?Date Boundaries} of a parameter field.

So I was linking the 2 formulas to the subreport and using them in the record formula like this

{DB.time} >= {@GetStartDate} AND {DB.time}<= {@GetEndDate}

using this, the subreport wouldn't be executed until I double-clicked on it even if the OnDemand option was not selected...

Hope this was clear,

Simon
 
I will try to see if I can get the same behavior, but I have never seen that. If you still have it, it might help to see the formula you used.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top