Combining address fields

Question:

I want to combine my existing single-line address fields (Address1, Address2, etc.) into a single multi-line field, without leaving blank lines in the address.

Answer:

You can use a simple formula field to combine the existing address fiields as follows:

'Address1'+"\n"+'Address2'+"\n"+'Address3'+"\n"+'Address4'

The "\n" strings represent newlines within the text, and you just need to make the formula field's box big enough to show the required number of lines.

The problem with the above formula is that if any of the address fields is blank, you will get a blank line in your new address.

To solve this, modify the formula as follows:

(If 'Address1'<>"" Then 'Address1'+"\n" Else "") +
(If 'Address2'<>"" Then 'Address2'+"\n" Else "") +
(If 'Address3'<>"" Then 'Address3'+"\n" Else "") +
(If 'Address4'<>"" Then 'Address4'+"\n" Else "")

Now any blank address lines are completely omitted, so you don't even get a newline.

Question:

OK, now I have a formula field which I can use for an address label, but I still have to enter the addresses in the old multi-line fields.

How can I get rid of the old address fields so I just enter addresses in the new multi-line field?

Answer:

Now that you have a formula field with the new addresses in it, you first need to return to browse mode to check that they are correct.

Having done that, you can edit the layout again, select the new address field, click on the "Text field" icon to change the field type to text, press Ctrl-Shift-G to edit the formula, press Ctrl-A then Delete to get rid of the formula, click OK, and then select the old address fields and press Ctrl-Delete to completely delete them.

If you now return to browse mode the new multi-line address field will contain the addresses, and you can modify or enter new data in this field in the usual way.


Back to DataPower 2 Documentation Page

Back to DataPower 2 Home Page