Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

So I am trying to concatenate a string which could consist of blank spaces or can have text into a report formula.

Below is the code I wrote in the formula field -

IF {Address1} = ''
 THEN
     ''
 ELSE
     {Address1} & Chr(13) & Chr(10) &

IF {Address2} = ''
 THEN
     ''
 ELSE
       {Address2} & Chr(13) & Chr(10) &

 IF {Address3} = ''
 THEN
     ''
 ELSE
        {Address3} & Chr(13) & Chr(10) &

 IF {Address4} = ''
 THEN
      ''
 ELSE
      {Address4} & Chr(13) & Chr(10)


The requirement is to print address and if there is a blank address line, it should not take a line space. This code works fine if all the fields have text in them. As soon as a blank space comes in any of the address line, it stop working. I know it is because of adding '' when the text in empty. Please suggest what fix I should make in this code or any other suggestion to fix this.

Thanks in advance.

What I have tried:

I have tried using Global variable, concatenate the blank space like this -

IF {Address1} = ''
    THEN 
        ''
    ELSE
        {Address1} & Chr(13) & Chr(10) & 
       
   IF {Address2} = ''
    THEN 
        ''
    ELSE
          {Address2} & Chr(13) & Chr(10)


which gives error.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900