A Boolean is required here in Crystal Report - c#

I want to show "NoData" if its value is less than Zero and "Commission" if its value is greater than Zero. When i show "String" its gave me error the boolean is required here and then if i do toText{VBookingCommission.MarketingPersonnelCommission1} it gaves me Error Convert it to String
This is my Query for Crystal Report
if({VBookingCommission.MarketingPersonnelCommission1}<0)
then "NOData" else "Commission";
If i do this its working Fine
if({VBookingCommission.MarketingPersonnelCommission1}<0)
then true else false;

The issue was that i was putting in under Suppress i need to put it in Formulas and i start working just fine!!!

I wrote a code like what you need. in formula edit form set visual basic instead of crystal report.
code:
if({VBookingCommission.MarketingPersonnelCommission1}<0) then formula="NOData" else if({VBookingCommission.MarketingPersonnelCommission1}>0) then formula="Commission"

This is happing because the variable type is Boolean. Either you need to use true or false.
OR
change the type of data of the variable and update the Data source using 'Verify Databases' or 'Set Datasource Location'

Related

unbounded field in crystal report by pass parameter at runtime

I have a report in crystal report.
In that report, I need to set the field to 'Go' if the value is 0, and set the field to 'NoGo' if the value is 1.
I have created an unbound field string and write formula as below:
if {?idline}=1 and tonumber({bevarage;1.torque})=0 then {#UnboundString2}='Go'
else if {?idline}=1 and tonumber({bevarage;1.torque})=1 then {#UnboundString2}='NoGo'
but this is not working and always returns an empty string from unbounded field.
Please help me to fix it.
Assignment operator in Crystal is := rather than =
Why not simply create a formula that depends on the parameter?

Pass a null date to a crystal report parameter using SetParameterValue

I have a situation where I have a crystal report where I pass in a start and end date via rdoc.SetParameterValue this works fine, except that, I do not want it to show a date if I pass nothing for the date variable, I just want it to be blank
To an attempt to do so i have written
if (DateStart != defaultDate)
{
rdoc.SetParameterValue("DStart", DateStart);
}else
{
rdoc.SetParameterValue("DStart", "");
}
Which gives me the error The types of the parameter field and parameter field current values are not compatible of course, this makes sense because I am trying to set a date to a string variable.
However, I am unable to think of a solution, nor do I see any solution in the Parameter's menu.
Appreciate it if I be given some assistance to solve this.
Regards
You may change the parameter type to string and pass the date as string:
DateStart.ToString()
I don't like this solution, but it works. Usually i just require the date.

conditions handling in reportviewer control

I have report in .rdlc format. I have inserted table in my report which is filled in programatically(in runtime) from datatable(which is also filled by dataadapter programatically). Also I want in table to use conditional formatting - background color of cell based on value. To do that in BackGroundColor property of needed column expression was inserted:
=iif(cdbl(Fields!MyField.Value),"Green","Yellow")
I haven't mentioned that all fields in my datatable are string. Therefore i use cdbl function to convert string to double. And when I render report, i don't have the desired result.
Therefore questions:
How to make sure there is no parsing error?
Is it possible to see step by step computation (as in excel)?
And what else error could be?
I suspect problem might be in culture.
The quickest way to test is to call
=iif(cdbl("3.14"),"Green","Yellow")
=iif(cdbl("3,14"),"Green","Yellow")
And see if it's working.
I don't have a reporting services right now and can't test it. I think you can do a tryParse in Reporting services.

How do I Color a label in reporting services based on a value in the dataset?

I have an SQL Server 2005 Express Reporting Server and I'm trying update a report to show a coloured label based on a value stored in the database.
I currently store the colour as an aRGB value, but I can change this if required.
I've seen posts on how to use expression in the color property, but I can't embed c# there.
Thanks!
SSRS uses VB.NET, not C#, and most places will accept code, it is prefixed with a '=' to let the parser know that it is code. I don't know exactly where you are trying to set the label (in a table, in a floating textbox, etc), but it is very likely that it is doable.
After some digging I found out that u have to use VB code.
Here's the steps.
Add a reference to System.Drawing in the report properties -> reference tab
Add this custom code to the report properties -> code tab
Public Function GetMyColour(myColour as integer) as string
Dim colorObj As System.Drawing.Color = System.Drawing.Color.FromArgb(myColour)
return String.Format("#{0:X2}{1:X2}{2:X2}", colorObj.R, colorObj.G, colorObj.B)
End Function
Set the color property expression on the report object you want set the color of to this
=Code.GetMyColour(First(Fields!RecipeColour.Value, "StockControl"))

How to programmatically change a Crystal Reports formula from Crystal Syntax to Basic Syntax - in Visual Studio 2005

I want to programmatically change formulas in a whole lot of reports, like in this question, but I also need to change the formula between Crystal Syntax and Basic Syntax. I can't see any way to do this in the object model. Is it possible?
i.e. I have a formula called 'Period' that already exists in a whole lot of reports, and it's currently defined in Crystal Syntax. I want to set the formula to be in Basic Syntax and provide updated text of the formula. I don't need to automatically convert the current definition from crystal to basic; I already have the new formula text.
If I simply loop through all the reports, open them, then set the FormulaFieldDefinition's Text property then the formulas are still set to 'Crystal Syntax' and won't evaluate correctly. Currently my only solution is manually opening each report, editing the formula, changing the dropdown from Crystal Syntax to Basic Syntax.
this http://msdn.microsoft.com/en-us/library/ms225743%28VS.80%29.aspx says that formulas are supported with Crystal Syntax and Basic Syntax - doesn't it automatically accept both of them?
Or do you want to convert between these two syntaxes?
I believe and #CodeByMoonlight confirms that this isn't available. So for anyone in the same boat as me with many reports to update: enjoy that manual process and hope you never have to change back!
You can walk through the report objectmodel like this.
Just change the formula and formula name.
public ReportDocument GetReport(DataSet ds)
{
const string formula = "WhileReadingRecords;" +
"<<your formula>>";
ReportDocument report = new InvoiceReport();
report.SetDataSource(ds);
// iterate report objects
foreach (ReportObject ro in report.ReportDefinition.ReportObjects)
{
if ((ro.Kind == ReportObjectKind.FieldObject && ro.Name == "<<FormuleName>>"))
{
((FormulaFieldDefinition) ((FieldObject) o).DataSource).Text = formula;
}
}
return report;
}

Categories

Resources