View Single Post
  #5   Report Post  
Larry Cohen via OfficeKB.com
 
Posts: n/a
Default

OK - let's say the data you are testing is called data_1, data_2, .... to
data_12. You want to have the value for data_1 to print on one row,
followe by the value for data_2 on the next row, etc. EXCEPT if and
data_# is blank, you want that row to collapse.

So the first step is to construct the table. Use the "Insert table" icon
to build the table with the number of columns desired, BUT with only 2 rows.

In the first row, type in the headers you want visible - that is fixed text
describing the column headings.

Next go to the first position on the next row (the only other row) that
will have the data_# value. This is where we are going to insert the first
IF....THEN....ELSE statement. I do this differently than most of the
commenters - I use the "Insert Word Field" button. (If this is not on your
mail merge toolbar ... use the drop-down arrow at the end of the toolbar,
add/or remove button .... click on mail merge, and click on the Insert Word
Field.

Back to that first position - click on the Insert Word Field and select
IF...THEN....ELSE. This opens a dialog box. In the Field name drop-down,
select the first keyword (Data_1). In the Comparison drop-down box, select
"is not blank." You do not need to fill in anything else; press ok. Now
hold down the ALT key and press/release F9 key. This will show you the
actual mail merge code. In the table cell you will now see:
{IF MERGEFIELD DATA_1 } "" "" "" }
That means, if the data_1 value is not null (first ""), then do what is
inside the second "", or if it is blank, do what is inside the third "".

Now place your cursor inside the second set of ""( where I show the plus
sign below).
{IF MERGEFIELD DATA_1 } "" "+" "" }
Then click on Insert Merge Field and select DATA_1. See below:
{IF MERGEFIELD DATA_1 } "" "{ MERGEFIELD "DATA_1" }" "" }

So this will print the value of Data_1 if it is not blank. Now this is an
IMPORTANT step. Move your cursor to the point just after the last curly
brace. See the plus below:
{IF MERGEFIELD DATA_1 } "" "{ MERGEFIELD "DATA_1" }" "" }+

At this point add the next IF...THEN...ELSE see below:
{IF MERGEFIELD DATA_1 } "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } "" "" "" }

The above may display on this site split into two lines.
OK, now the next IMPORTANT step. Go to the point in the second If
statement - the second set of "" where we will insert the "insert merge
field" but do not do that yet.

See the plus sign below:
{IF MERGEFIELD DATA_1 } "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } "" "+" "" }

Put your cursor there between the second set of "" and key in 2 returns,
and then insert merge field (data_2). It should look like below:

{IF MERGEFIELD DATA_1 } "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } "" "

"{ MERGEFIELD "DATA_2" }" "" }Next If statement here.


You will keep doing the above until you have your 12 mergefiedl
IF..THEN..ELSE statements.
What we have done is use one cell to hold all of the "rows" separating each
active row with a blank line. So you might see

Label row
---------------------
Data_1

Data_3


or

Label row
---------------
Data_5

Data_7

Data_8

Data_10


Hope this helps.
I actually found a way, in my application which required over 100 rows, to
copy the label row to each page. That's for another time.

--
Message posted via http://www.officekb.com