hi all,
actually i want to pass String value in Farmula fields in crystal report X1 Release 2 .but only numeric value can be passed.
in crystal report 8 it is possible that u can pass value of any type.
any one can help this artical.
thanks
Irfan Ullah

Dani AI

Generated

Quick, pragmatic notes for passing string values into a Crystal Reports XI R2 formula field.

The symptom you described usually comes from one of three causes: the report expects a formula expression (not a raw value), the source field/parameter type is numeric in the report or database, or the code that assigns the value is not quoting/escaping the literal correctly. As hinted, first confirm the report’s source fields and any parameters are defined as text where you expect strings. As observed, the formula container must receive a proper quoted string or parameter value.

Two reliable ways to supply a string from ASP.NET/VB.NET:

  • Use a string parameter on the report (recommended). Simple and type-safe; set it from code before binding the report.
Dim rpt As New ReportDocument()
rpt.Load(Server.MapPath("MyReport.rpt"))
rpt.SetParameterValue("MyStringParam", "Hello world")
CrystalReportViewer1.ReportSource = rpt
  • If you must set a formula definition, assign a valid Crystal formula expression (a quoted string). Using Chr(34) avoids tricky quote escaping in VB:
rpt.DataDefinition.FormulaFields("MyFormula").Text = Chr(34) & "Hello world" & Chr(34)

Troubleshooting tips: ensure you assign values after Load and before binding the viewer; call rpt.Refresh() when needed; if the formula still evaluates numerically, verify its return type in the formula editor (wrap with ToText(...) inside the report if necessary); escape embedded quotes/apostrophes or use Chr(34). Also confirm the Crystal runtime/assemblies on the server match the report version. These checks should resolve the "only numeric" behavior you saw.

Recommended Answers

All 2 Replies

then make sure that-
u have declared all the variables in the table(i.e, while creating table ,make sure that "name" field is declared as varchar,"age" is declared has "int")And if u dont do so,all the variables in crystal report by default becomes integer variable..
so,check it out....

Hi,

Check this:

crxrpt.FormulaFields.Item("myFormula").Text = "'ABCDEF'"

Note the Text is First Wraped with single quote and then with double quote

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.