I placed my field ParentDied from table tblSIF onto my page report. If the report loads, the condition should be:
IF ParentDied = 0 THEN 'None' ELSE 'Deceased'
I searched on the Internet and found this:
`IF {#Ship Days} = 0 THEN "Same Day" ELSE {#Ship Days}`
Where did #Ship come from? Is that a parameter? All I know is that the field is named by CR as tblSIF.ParentDied. How can I make a formula of my own?
To create and use a formula on your report follow these steps:
Right Click Formula Fields and select New...
Input a name for your formula
In the Formula Workshop add in your expression
Based on your example this will be something like:
If {tblSIF.ParentDied} = 0 Then "None" Else "Deceased"
Drag the report onto the report to display
Design:
Preview:
Related
I am attempting to add an approval signature to a crystal report. The approver is not always the same person, so the signature will change based on who approved it.
You can insert just one image.
Right-click it and select Format Graphic
In the picture tab, enter a dynamic expression (IF THEN ELSE or SELECT CASE) for the Graphic Location property.
Add all the images in report and write supress condition for each image according to the selection of parameter.
For xyz image add supress condition as
E.g
if parameter = 'xyz'
then false
else true
I have a report containing some sub reports and in my main report i am showing the sub reports based on scan mode and status coming from query.
Now i need to show a message whenever sub reports don't have data.
I tried like this.
checked supress blank sub report and supress blank section for all reports.
1.Kept a text box in report footer of main report.
2.Took a field (Say Barcode) from sub report and passed to main report using shared variable.
3.In section expert of text box wrote like this.
not isnull(Barcode)
But it is not working.
Please suggest.
If I have understood this correctly the code below should work. Tip, avoid using NOT ISNULL. If possible just change the outcome order of your IF statement as below.
To make your formula more robust also, it's a great idea to add in the:
OR = ""
To account for any blank entries.
Final code:
IF Isnull({Barcode}) OR {Barcode} = "" THEN FALSE ELSE TRUE
I hope some one must have dealt this situation before.
I have a crystal report and on that report I have different sections including headers ,detail and footer. I'm displaying parts related information on details section and description is one of the fields thats being displayed.
So now based on part's description(in detail section)I have to display some text on the page header. So I have to look for part's description for every single part ,and if even a single part has the given description out of all the parts I have to print a message on report header.
My assumption is to use conditonal suppress option at the page header section, but not sure how to check for values from details section at the page header level.
Any help will be highly appreciated.
Thanks
NAF
Here's the way I would approach it.
Create a formula which returns 1 when your condition is met- otherwise 0. For example:
if {table.field} like '*acid*' then 1 else 0;
Then your conditional surpression can sum your new formula- and if the result is 0 it will hide the message.
sum({formula}) = 0
If you want to display it in Report Header then i would use a SQL Expression to conditionally suppres the text you want.
The SQL Expression
(select count(1) from dbo.TABLE where description = 'my_description')
Then in the Suppress formula:
{?SQL_EXPRESSSION} = 0
Here is a strange problem I have run into.
My record select formula is as follows, I have dumbed it down for purposes of this error:
reportDocument.RecordSelectionFormula = " {#ClientName} = 'Smith' "
If I copy this exact selection statement into Crystal it previews fine, but when run from .NET I get
'This field name is not known'.
The problem is occurring at the #ClientName formula field.
#ClientName simply contains:
formula = {aw_illust.CL1LNAM}
I can also set it to just a blank string (formula = "") and it still gives
'This field name is not known.'
Here is the strange part, if I bypass the formula and put the formula text straight into .NET everything works fine.
reportDocument.RecordSelectionFormula = " {aw_illust.CL1LNAM} = 'Smith' "
That is the same record selection, except with the '#ClientName' formula replaced with '{aw_illust.CL1LNAM}'. It just happens on this one report, I have many other Crystal Reports working with formulas referenced in .NET just fine. Any ideas?
Most likely you are not using your {#ClientName} formula anywhere on report; Crystal Reports tends to ignore unused fields, formulas etc. Place {#ClientName} field somewhere in report (header or some similar section) and suppress it - this way you don't mess up report design, but CR should know about that formula afterwards.
Which syntax has the formula? If it is crystal syntax then change it to basic syntax. Or change the content of the formula to crystal syntax (without "formula =")
You could create a parameter like {?ClientName} and set that from .NET, and then put a select formula in Crystal like {#ClientName} = {?ClientName}.
Can you save the report with the selection criteria you'd like then display what the reportDocument class sees using something like:
TextBox1.text = reportDocument.RecordSelectionFormula
This would confirm that your syntax is correct.
Same happened with me when I copied existing report to be used as the new one, You can first open report in report viewer ,In my case
but the query that loading report has no selection with name DateLocal Transaction so I got this error, the resolve is to either use only those that are require (Extras has nothing to do with the error) or rename selection value in query.
Basically I have a field in my table called sex, and it's a boolean. true for male, false for female. How can I display it this way instead of as 0, 1?
You want to create a formula field and add the formula field to the report instead of the sex field. Something like this should work (my syntax may be slightly off)
if {MyTable.sex} = 1
then
"male"
else
"female"
If you are unfamiliar with formula fields they are just expressions you can use and display in the report. In the 'Field Explorer' side bar in Crystal Reports you can see list of all the Database Fields etc. Just right click on the Formula Fields and add a new one. After you create the formula field you drag it onto your report layout just like any other normal field.
Use a formula field. Put, say, #Sex into your report, then edit it to be something like:
//may need tweaked....
If {database.table.sex} then
male
else
female;
My Crystal formula syntax is really rusty, so that may not be right as written. It might need to be :
//may need tweaked....
Stringvar displaySex;
If {database.table.sex} then
displaySex = "male"
else
displaySex = "female";
displaySex
And the line-end (";") format might not be right....
If you right-click on the original database field and choose "Format Field...", you can set the Display String on the Common tab using one of the formulas above, instead of creating a separate formula to do the calculation.