Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: problem filtering two subreports Post Reply Post New Topic
Author Message
pedroponting
Newbie
Newbie


Joined: 28 Apr 2008
Online Status: Offline
Posts: 6
Quote pedroponting Replybullet Topic: problem filtering two subreports
    Posted: 29 Apr 2008 at 4:14pm
(Apologies for cross-posting! I put it in the wrong forum by mistake to start with.)
This seems like madness to me, but here you are:

I have two subreports embedded in my main report. I filter the DataSet for a date range prior to viewing the report. The problem is that when I display the subreports, only one of them (the one I apply the filter to last) actually gets filtered. The other shows results for all dates.

Here's the code I'm using:

        private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
           
            MainForm = (frmWorkReport)this.Owner;
            this.tasksTableAdapter.Fill(this.workreportDataSet.Tasks);
            this.staffTableAdapter.Fill(this.workreportDataSet.Staff);
            this.prioritiesTableAdapter.Fill(this.workreportDataSet.Priorities);
            this.projectsTableAdapter.Fill(this.workreportDataSet.Projects);
            this.KRAsTableAdapter.Fill(this.workreportDataSet.KRAs);
            tasksReport1.SetDataSource(workreportDataSet);
            FilterData();
        }
        private void FilterData()
        {
            string filter;
            filter = <snip>; //removed for simplicity's sake. The filter expression works fine

            tasksReport1.DataDefinition.RecordSelectionFormula = filter;

            ReportDocument srProj = tasksReport1.OpenSubreport("rptProjects");
            srProj.DataDefinition.RecordSelectionFormula = filter;

            ReportDocument srKRAs = tasksReport1.OpenSubreport("rptKRAs");
            srKRAs.DataDefinition.RecordSelectionFormula = filter;

        }

If I reverse the order of the filter assignments, then the  result is reversed. It is always the second subreport assigned a filter that gets successfully filtered. I can't filter both subreports at the same time!

I've got Brian's book since yesterday and searched it for any reference to this, but so far haven't found a solution. Help anyone?

------------
laziness is the father of invention
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.