Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Hello,

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;

rdReport.Load(reportPath);

/* set the datasource */

rdReport.SetDataSource(ctrlbase.ResultSet.Tables[0]);

/* 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);

paramField.ApplyCurrentValues(paramValues1);

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.

Thanks,

BG

Former Member
Not what you were looking for? View more on this topic or Ask a question