Crystal Reports: Displaying a record if another record is null, and vice versa - crystal-reports

I am building a subreport and have two tables from which I am using one field each containing a phone number.
Original Number {TABLE1.ORG}
Temporary Number {TABLE2.TEM}
What I want:
If {TABLE2.TEM} is not null, then hide {TABLE1.ORG}, else show {TABLE1.ORG}
I tried to use the above as a formula but it doesn't work too Since these both fields are from two different tables if place them next to each other (without any formulas or suppression) in the design mode:
{TABLE1.ORG} {TABLE2.TEM}
...I see them on different lines in preview mode:
+971 4 321321321
+971 4 123123123
Maybe because the formula reads records and evaluate from the same line, I guess this is the reason why above is not working correctly.

It's not obvious why the two fields are appearing on different lines in preview mode, but it's unlikely to be because they are from different tables - it's more likely to be because there isn't enough room in the layout for them both to display in one line, and so they are growing to a size that canb be displayed.
To conditionally suppress {TABLE1.ORG} based on whether the other field is not null:
right-click on {TABLE1.ORG} and select Format Field...
in the Common tab within the Format Editor dialog, click on the conditional suppress formula button x-2 and enter the formula not IsNull ({TABLE2.TEM}) in the Format Formula Editor.
click Save and close to exit from the Format Formula Editor, then click OK to exit the Format Editor dialog.
If you now preview the report, you should find that {TABLE1.ORG} is suppressed where {TABLE2.TEM} is not null.
Note that if you make display of both fields conditional on whether the other is null, then both will be suppressed where neither is null.

Related

How to show and hide a LineObject by using formula in crystal report?

I'm using a Crystal Report connected with VB.NET 2010, here I using a Line object, which I need to show or hide depending on data field. Where do I need to set the formula?
This project I use is running with SQL 2008 and VB.NET 2010. I've tried some Formula Field for this topic. But the result is not look like that I want to show.
I use the following code on Formula Field:-
IF isNull({PrintParticularList.CUST_INVOICE_No}) or {PrintParticularList.CUST_INVOICE_No}=""
THEN
""
ELSE
"--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
I also try this following Code :-
IF isNull({PrintParticularList.SLNO}) or {PrintParticularList.CUST_INVOICE_No}=""
THEN
Line25.Suppress=True
ELSE
Line25.Suppress=False
But here I got error on Line25.
A number, currency amount,boolean, date, time, date-time, or string is
expected here.
In the Report Designer use the Insert Line tool to draw the line where you want it to appear on your report. The right-click the line object and select "Format Line..." to open the Format Editor dialog box. On this window you will find a check box labeled "Suppress" with an X-2 button to the right. Click the X-2 button and this will open a Formula Workshop window where you will enter the formula that determines if this drawing object should be suppressed or not.
I would recommend the following formula based upon your previous attempts at creating one.
IF isNull({PrintParticularList.SLNO}) or {PrintParticularList.CUST_INVOICE_No}="" THEN
True
ELSE
False
-----EDIT-----
Since you don't have the X-2 button I have 2 more ideas.
1.) Take the 1 section you current have and split it into 3 sections. Then you could place all the content above the line in the first section, place the line in the second section, and the content below the line in the third section. They use the formula to suppress the second section when the line is not needed.
2.) Insert a blank text box in place of the line and set either the top or bottom border of the text box to a single line. Then use the suppress formula to determine if the text box should be shown or hidden.

Crystal Reports XI, disappearing field with zero balance

I have crystal reports XI, I am new to crystal reports and am not tech savvy, so please consider that in your reply. There is a section that does not populate at all when the value is zero. The whole section disappears on the generated reports. I need the section to show and I need the zero value to show. Any suggestions?
do a right click on that section(where the section name is), go to section expert and on the common tab see if you have something under Suppress(No drill-down) X-2 button(might be red). There should be a condition that is suppressing the section when the field takes 0 value. You can suppress that condition putting // in-front on it or just delete it. You may also check if Suppress Blank Section is checked, if so remove the check mark.

New line return in Crystal Report

Im creating a report based on crystal report.. I'm wondering how can i return a new line like for example im a field which is bound to a a datatable where in if the number of text reach the maximum width of the field it would carry to the next line?.
Like if i had a text that is "Representation and other incidental allowances" since it exceeds the width of my field , i want to display like below:
"Representation and other
incidental allowances"
Hope someone could help me!.. Thank you!
Campagnolo_1 says you will need a formula, but I can assure you a formula is not necessary. All you need to do is place your column where you want it, give it the width you want, and right click on the field, select "Format Text", go to the tab labelled "Common" and check the box next to "Can Grow". To the right of this option, you will be able to select how many lines this field can 'grow', in other words, this is how many additional lines the field will use to display your text.
You will have to create a formula in the "Can Grow" option under "Format Field" (right-click on field). You will have to specify after how many characters you'll want the new line, so that could be tricky if your text changes.

Hide row (and remove whitespace placeholder) of tablix in Reporting Services 2008

I have a row in a tablex that I want to hide based on a condition. I can do this with the visibility property and also using CanShrink as well is an option.
I've tried both of these and the best I can do is hide the row (make it invisible), but it keeps the whitespace it takes up - I need to remove the whitespace too so if it is not shown that it doesn't take up paper/viewing space.
I have also made the height of the row very small and put cangrow=true so that that if i populate the field with data based on an expression it will grow to the right size but this is not ideal because there is still 0.03125in of space for the row that is always shown (minimim height) and if it grows it grows to fit the text but not neccessarily the set size I want.
I thought I had done this before in an older version of RS but I can't seem to get it to work correctly in this version (2008).
Any ideas?
Try to set the Hidden property of the Static Row Group under the Details Group, in this case the whole row will disappear instead of the content of the textboxes.
If you are using Report Builder, you need to switch to Advanced Mode (make sure that the Properties and the Grouping windows are displayed, go to the upper right side of the Grouping window and press the black triangle):
Click on the second "Static" item under the "(Details)" group and you can set the Hidden property on the Properties window.
Link to MSDN sample
A simpler way to get to this option for hiding a row is to right-click on the row header and select "Row Visibility". From there you will get a dialog where to can enter an expression.
I was able to make the rows go away by setting the following 2 properties
textbox.CanShrink
row.Hidden
I played w/ row.HideIfNoRows and it seems to have no effect in accomplishing the desired outcome described by op.
Click on textbox, these one is in the properties of the textbox
(if there are multiple columns, I assume you will have to make this setting for each cell/textbox, in my case, I only had 1 column)
CanShrink=false
For the next property, you have to go into ADVANCED MODE by clicking the down arrow at the right side of the Row Groups/Column Groups pane.
Click on the Row containing the line you would like to hide.
The Hidden property can be found in properties pane...
This is an alternate way to set Hidden, as opposed to right clicking the Row Header in the actual Tablix.
Hidden= <expression describing when you want the row hidden hidden>
One other note - If you right click the Row Header and choose 'Row Visibility' you get a dialgue. the Row Property dialog has a caption "Show or Hide Based on an expression".
The actual behaviour is It will HIDE the row if the expression evaluates to TRUE.
IMHO - this is misleading, at best ambiguous.
Once you understand the property you are actually setting is called HIDDEN, then this makes sense. Until then, I certainly assumed I was setting a property called Visisble... FWIW....
On the empty row you want to hide, go to the text box properties and go to expressions -> visibility, then show or hide based on an expression and use
=iif(first(Fields!.Value = ""),true,false)
Setting row visibility logic is important, but I've learned that sometimes a blank row will still appear, even though its contents are hidden. To solve this, I had to do the following non-intuitive steps, but I did in fact succeed in completely suppressing unwanted white space.
In the cell in the tablix region, use the Insert > Rectangle menu option.
In the rectangle, use the Insert > Textbox menu option. Resize as needed.
In the textbox, right-click and enter a placeholder.
Set the value of the placeholder expression to whatever you need.

How to handle variable width FieldObjects in Crystal Reports

I have a Crystal Report which is viewed via a CrystalReportViewer control on an .aspx page (using VS2008).
The report has two data-driven FieldObjects (which can contain a variable number of chars) which I would like to display on the same line beside each other.
Problem is when the text in the first FieldObject is too long it overlaps the text in the second FieldObject.
I have tried setting the 'CanGrow=True' and 'MaxNumberOfLines=1' on the first FieldObject to 'push' the second FieldObject further to the right, but this didn't work.
How do I get the second FieldObject to always display immediately after the first FieldObject regardless of the length of the text in the first?
Cheers in advance of any knowledge you can drop.
you can add a text object to the report. And while editing the text of the text object, drag the field you want to show from the object explorer into the text box. Then hit space, then drag the second field in to the same text box. Your two fields will always be one space a part. You could, of course, add more spaces or any other text you want.
Or you can create a function which returns field1 + " " + field2 and add the function to the report.