Skip to Content
author's profile photo Former Member
Former Member

VS2005 CR2008: Selectiong Formula not working

Hi all,

I've created some reports using CR2008 which work just fine (the correct records are displayed) when I run them from the reports designer or when I pass the Selection Formula through code. If I set the parameters through code, then no filter is applied, and all records are displayed.

Does anyone faced this problem? Can someone suggest a solution?

Hope someone can help.

Best Regards,

Vítor Vieira

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2009 at 07:33 PM

    Hi,

    Try using Inproc RAS SDK for adding or changing the record selection formula through code.

    Please try following code:

    // Load the report file for this sample from the file path indicated.

    string sampleReportPath = @"Path of the report";

    CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

    rd.Load(sampleReportPath);

    // Access the ReportClientDocument API in-process using the ReportDocument class.

    ISCDReportClientDocument rcd = new ReportClientDocumentClass();

    rcd = rd.ReportClientDocument;

    // Create a FilterClass instance.

    Filter filter1 = new CrystalDecisions.ReportAppServer.DataDefModel.FilterClass();

    // Set the filter formula text using the FreeEditingText property.

    filter1.FreeEditingText = "{Customer.Last_Years_Sales} > 200000";

    // Use the Modify() method of the FilterControllerClass to apply the filter.

    rcd.DataDefController.RecordFilterController.Modify(filter1);

    // Set the report source of the Crystal Report viewer to the instance of the report.

    crystalReportViewer.ReportSource = rd;

    Hope this helps.

    Thanks,

    Prasad Kanchan.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.