Note: This is a repost but useful. It's important to follow the steps exactly. Everything is case sensitive. Also when you type the two "" quotes, don't put a space between them. If you have spaces in your database, this won't work. Either change the database field names, or create a query based on the table, and change the field names in the query. Then base the labels on the query.
Here it is -- suppressing a blank Address2 field in your mail merges. It's not extremely simple, but it's reasonably straightforward and it works.
Here's the situation we're addressing. Sometimes your addresses have two lines for the address part, sometimes they don't.
Bob Jones
101 Main
Suite 55
Boulder, CO 80022
Marion Silverman
888 105th Ave
Broomfield, CO 82211
But you have to put in the <Address2> field for everybody, since it's a mail merge. The setup has to be the same.
<Firstname> <Lastname>
<Address1>
<Address2>
<City>, <State>, <Zip>
But with this approach, your addresses look like this.
Bob Jones
101 Main
Suite 55
Boulder, CO 80022
Marion Silverman
888 105th Ave
Broomfield, CO 82211
Ick. How do you suppress that second Address2 line and the corresponding carriage return if there's no content for a particular record, for that Addres2 field?
Select the Address2 field in your mail merge document, choose Insert > Section, and create a conditionally hidden section with this formula.
databasename.tablename.fieldname EQ ""
Here are the details, using an example of labels.
1. Create the labels for mail merge as usual. File > New > Labels, select your database and tables, insert the fields, etc.
2. Choose the Synchronize Contents checkbox.
3. Click New Document.
4. Here are the labels.
5. Turn on nonprinting characters if they're not on already.
6. Select the first soft return, shown selected.
7. Press Return or Enter to replace it with a hard return.
8. Repeat, to make them all hard returns.
9. Click Synchronize to update the other labels to be the same.
10. Select the Address2 field.
11. Choose Insert > Section.
12. Name the section Suppress. Select the Hide checkbox and type the following condition. The screen shot shows the syntax.
Syntax
databasename.tablename.fieldname EQ "" � �(the last part is two double quotes together)
Example
databasewithtwoaddresslines.Table1.Address2 EQ ""
NOTE: if you are using the Thunderbird address
book as a data source, you need to use square brackets if the field
name includes a space (i. e.: [Address 2]=="") to hide the second line of the address if it the Address 2 field is blank.)� I would suggest in general avoiding field, table, or database names with spaces.
http://www.oooforum.org/forum/viewtopic.phtml?t=43528&highlight=
Click the screen shot to see it bigger. It shows the syntax, not an actual example.
13. Click Insert.
14. Click Synchronize.
15. Now preview the data or print the data and you'll see that it prints correctly.
15. If you need to change the section, select it in the first address and choose Format > Section. Select the one named Suppress for the master label and make changes, then click OK. Click Synchronize again in the labels.