cancel
Showing results for 
Search instead for 
Did you mean: 

Filter data in subreport based on a value passed from main report

Former Member
0 Kudos

Hi All,

I am using crystal report 2008.

In the crystal report that I have designed, has a main report and a subreport.

A date value from main report has to be passed to the subreport and based on that date, the records should be filtered, in the sub report.

What I have done is created a shared variable for this date value, in the main report,like below. The value is pulled to report and is showing the correct value in main report.


WhilePrintingRecords;

shared datevar shdtvlu;

shdtvlu:={@dtvlu1};


Same has been created in subreport and is showing the date value, correctly,in the subreport.

shared datevar shdtvlu;

shdtvlu;

Now the result in the subreport ,should be filtered ,based on this value.

All the records,less than this date, should be shown in the subreport.

Can anyone please guide me on this regard? Is there any alternate way, other than my approach to accomplish this.

Thanks to all the helping hands out there..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Ann,

There should be a link between main report and sub report to filter data.

You have to link your main report date filed with other date field in your sub report using links tab.

Then you will get sub reports data based on main report

Former Member
0 Kudos

Hi Vissu Pangam,

I have tried the linking ,but the data is being pulled is not filtering as per the date, its taking all the records.Please see below for the linking that I have done.Is it correct??

Thanks,

Ann

Former Member
0 Kudos

Hi Ann,

What is the filed you used in sub report to create @Sharedt formula ?

Or simply you created a formula to get date value from main report ?

Former Member
0 Kudos

Hi Vissu,

I used the following formula, as I mentioned in my question, to create @sharedt formula in subreport.

shared datevar shdtvlu;
shdtvlu;

Former Member
0 Kudos

Hi

you can't filter sub report data based on main report unless there is a link between the fields from main report to sub report.

Here you are not linking main report field with sub report

You are just getting date from main report and linking same date from sub report which is of no use to filter data in sub report.

You have to get a filed from sub report (date) and then link with main report to get filtered data.

Simply there should be a data field coming from sub reports query.Then link this with main reports date filed

Former Member
0 Kudos

Hi,

I am pretty much new to subreports and the linking from main report to subreport.

Is it the way, like shared variable I created in the mainreport is linked to a date field in main report. Same like that the shared variable ,in the subreport also has to be linked to a field in the subreport, right?

Thanks,

Ann

Former Member
0 Kudos

Hi Ann,

No need of shared variable concept here.

You have to do like this.

Lets say I have a date field in main report So I need to filter sub reports data based on this date field.

So to do this you need to have a date filed in sub report also.Means it should be in sub reports command object(query)

Then link date field from main report to sub report using links tab.

Former Member
0 Kudos

Hi Vissu,

Thankyou for the help. I try it.

Answers (0)