How To Set Textbox1 Value Into Formula Field Of Cystal Reports
Solution 1
Dim RptForm As CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim T As CrystalDecisions.CrystalReports.Engine.TextObject
RptForm = New MyCrystalReport()
T = RptForm.ReportDefinition.Sections(0).ReportObjects("TXTCNAME")
T.Text = DTPTDate.Value
Here TXTCNAME is the name of textbox present in Sections(0) of Crystal Report
MyCrystalReport is the crystal Report you want to use.
Solution 2
when the Crystal report formula field is a DateTime , then the following code will helps you:
CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new ReportDocument();
rd.Load("AgedItems_3.rpt");
try
{
string datetext = RunDate.ToString("dd/MM/yyyy HH:mm");
rd.DataDefinition.FormulaFields["ProcessDate"].Text = "#"+datetext+"#";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
crystalReportViewer2.ReportSource = rd;
Related videos on Youtube
Comments
-
mahesh almost 2 years
I want to set textbox1 value into formula field of crystal reports and Utilise the same value into crystal reports.
Suppose my Textbox1 value is “12000” and I want to set it to formula field and utilize the same into crystal reports. Is it possible?. And yes then How?.
Note: textbox1 located on top of CrystalReportviewer1.
Solution
It is very simple just create the instance of the reports class and set the textBox value in your crystalreportviewer source as under:
PLCrystReport plc = new PLCrystReport(); plc.DataDefinition.FormulaFields["ttt"].Text = "" + textBox1.Text + "";
For above first you have to create the formula field in your crystal reports and set the above code then after copy your formula field to your crystal reports. It will shows the specified value of textbox into formula field.
Note ["ttt"] is the formula field name. which provided into crystal reports.
-
nh32rg over 6 yearsin vs2015 this is FormulaFields.Item("ttt").Text
-