on 04-17-2015 12:02 AM
I have an issue where I have created a report and I am using C# code to retrieve a value from a SQL server database and the way the value is displaying on the report is wrong.
The value from the database is "123456" but on the report it is showing up as "123,456.00"
I have tried to format this field every type of way but it always appears the same. It is currently a Formula Field because this number will be used in another Formula Field to generate a barcode.
I created another Formula Field and used
Replace(Replace(ToText({@TagID}),",",""),".","")
That replaced the comma and decimal point just fine, but the zeros remained, displaying the value as "12345600"...still wrong. I do not want a hack type of solution to remove trailing zeros, because some values put into that database might have zeros, such as "500" or "1000".
It seems like the system in which formatting objects in Crystal Reports inside Visual Studio is very limited. Please tell me there is a solution for this issue, it is so tedious!
Thank you for your time!
Hi Michael,
Use:
ToText({@TagID},'#')
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ToText({@TagID}, 0, "") results in 'Too many arguments have been given to this function'
I am assigning a value to the @TagID formula in my C# code:
theReport.DataDefinition.FormulaFields["TagID"].Text = "" +TheTag.ToString() + "";
'TheTag' being any integer, such as 123456 (showing up in the field as '123,456.00' and I HAVE tried formatting the field using the field properties available within Visual Studio but nothing I changed had any effect on this field...
Another way is to get CR to check the formula before adding:
String FormulaMessage; // if not null that is the error message
try
{
FormulaMessage = "\n" + rptClientDoc.DataDefController.FormulaFieldController.Check(resultField);
}
catch (Exception ex)
{
btnReportObjects.Text += "\n" + ex.Message + "\n";
FormulaMessage = "";
btnCount.Text = flcnt.ToString();
break;
}
textBox1 = "";
if (FormulaMessage != null)
{
btnReportObjects.Text += FormulaMessage.ToString() + "\n";
if (FormulaMessage != "\n") // || FormulaMessage.Substring(0, 14) == "Error in formula") //\nError in formula ~: \n'NumberVar DoBVar := IIF((100 * MONTH(currentdate) + DAY(currentdate)) < (100 * MONTH({Command.BirthDate}) + DAY({Command.BirthDate})), 1, 0);\r'\nThis field name is not known.\nDetails: errorKind"
{
FormulaMessage = @"This field name is not known";
btnReportObjects.AppendText("\n");
++Errorcnt;
btnErrorCount.Text = Errorcnt.ToString();
//string myURL = @"http://search.sap.com/ui/scn#query=" + FormulaMessage + "&startindex=1&filter=scm_a_site%28scm_v_Site11%29&filter=scm_a_modDate%28*%29&timeScope=all";
//string fixedString = myURL.Replace(" ", "%20");
////System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Internet Explorer\iexplore.exe", myURL);
//System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe", fixedString);
}
}
Don
PS - if you want to catch errors or exceptions you can use the above code to open a browser and search SCN ( SAP public forums ) for the error... Or redirect it to your own Forums for support...
Moved to .NET SDK forum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.