Skip to Content
avatar image
Former Member

Crystal Rpeors XI (VS 2003) ASP.NET - Changing formula at runtime


I am using CR XI and VS 2003 to create a web application that displays a report in a crystal reports viewer object.

The users basically go to a web form and inputs some selection criteria. I then open a dataset and bind it to the report. Everything is working great except I can not seem to get the report formulafields to process in the crystal reports viewer. The report runs fine, but there is a formula field in the Report Header that needs to be changed at run time. The report runs and show the data, but does not show the report header text (formualfield). When I print the report from the crystal reports viewer to pdf the header does show up correctly.

Code snipet after dataset is built/opened:

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

string reportPath = ((AmeriReportBase)ctrlbase).REPORTFILE;


/* set the datasource */


/* update the formula fields */

rdReport.DataDefinition.FormulaFields[0].Text = "StringVar sTitle;" +

"IF (1 = 1) THEN "+"sTitle := \"ABI Hold Items for \" + {SP_ABIHoldItems;1.Customer};";

rdReport.DataDefinition.FormulaFields[1].Text = "1 > 12;";

/* update the report source */

((AmeriReportBase)ctrlbase).Report.ReportSource = rdReport;

/* make it visible */

((AmeriReportBase)ctrlbase).Report.Visible = true;

/* update parameters */

CrystalDecisions.Shared.ParameterField paramField1 = ((AmeriReportBase)ctrlbase).Report.ParameterFieldInfo["@nDetail"];

paramField1.ReportParameterType = CrystalDecisions.Shared.ParameterType.ReportParameter;

CrystalDecisions.Shared.ParameterField paramField2 = ((AmeriReportBase)ctrlbase).Report.ParameterFieldInfo["@CustomerCode"];

paramDiscreteValue1 = new CrystalDecisions.Shared.ParameterDiscreteValue ();

paramDiscreteValue2 = new CrystalDecisions.Shared.ParameterDiscreteValue ();

paramValues1 = new CrystalDecisions.Shared.ParameterValues ();

paramValues2 = new CrystalDecisions.Shared.ParameterValues ();

CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField = rdReport.DataDefinition.ParameterFields["@nDetail"];;

paramDiscreteValue1.Value = 1;

paramDiscreteValue2.Value = "LIGO00";

paramValues1.Add (paramDiscreteValue1);

paramValues2.Add (paramDiscreteValue2);


paramField1 = rdReport.ParameterFields["@nDetail"];

paramField2 = rdReport.ParameterFields["@CustomerCode"];

paramField1.CurrentValues = paramValues1;

paramField2.CurrentValues = paramValues2;

The formuals above are for test only.

Any help would be greatly appreciated.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 02, 2008 at 03:37 PM

    Hi, BG;

    Try setting the ReportSource property of the viewer as the last thing you do.



    Add comment
    10|10000 characters needed characters exceeded