Technique to hide whitespace if the textbox value is not present in a report in Dynamics NAV - CloudFronts

Technique to hide whitespace if the textbox value is not present in a report in Dynamics NAV

Introduction:

In this article I will be giving the procedure required to hide whitespace if the textbox value is empty and hence not displayed in a report of Dynamics NAV.

Pre-Requisite:

Microsoft Dynamics NAV

Procedure:

1. I have created a simple report with four field values from Customer table for demonstration.

2. I want to display these four fields in a report. So I have created a textbox in the report with these four field values. Instead of creating four different textboxes, I prefer only adding one textbox and giving a line break between each field.

3. The value of the expression of the textbox is as follows:

=First(Fields!Name_Customer.Value, "DataSet_Result") & "<br/>" & First(Fields!Address_Customer.Value, "DataSet_Result") & IIf(First(Fields!Address2_Customer.Value, "DataSet_Result")<>"","<br/>","") & First(Fields!Address2_Customer.Value, "DataSet_Result") & "<br/>" & First(Fields!City_Customer.Value, "DataSet_Result")

 Expression A

I’ll explain the Expression A below in detail: 

a. “<br/>” is added to insert a line break between each field value. But this expression is used in HTML. So we need to set the textbox to Interpret HTML tags as styles. Hence, you need to double click on your textbox expression. On double clicking the expression, a window opens up which is the Placeholder Properties window. In the Placeholder properties window, set the ‘Markup type’ to ‘HTML-Interpret HTML tags as styles’.

b. Now, there is a possibility that ‘Address 2’ field value of the Customer can be empty at times. So a whitespace will be displayed in the report. So to remove the whitespace, I have put the below expression in Point no.: 3

IIf(First(Fields!Address2_Customer.Value, "DataSet_Result")<>"","<br/>","")

 This means that if the Address 2 of the Customer has a value there will be a line break and if no value is present nothing will be displayed and there will be no line break too. Hence whitespace will not be visible in the report. This can be done for any field value which has a possibility to be empty.

The output of the report looks like below:

I executed the report for Customer No: 01445544-Progressive Home Furnishings

If the Address 2 field value is empty: 

Report preview is as below: 

If the Address 2 has a value present: Report preview is as below: This is the simplest way to hide whitespace in a report if the textbox value is empty.


Share Story :

Secured By miniOrange