How can I use "Skip record if.." along with "Next record if.."?

J

jewell

How can I use "Skip record if.." along with "Next record if.." both in a mail
merge? I have multiple records being merged dependant on a unique field but
they unique field for varies. I have 4 lines using the "Next Record" and am
getting 4 lines of merged data but some have only 2 or 3 lines. When those
get merged it picks up the next record for the next client and I don't know
how to make it skip and begin a new label. Help!
 
D

Doug Robbins - Word MVP

Although you do not specifically say so, I suspect that you are probably
trying to perform a "multiple items per condition (=key field)" mailmerge
which Word does not really have the ability to do:

See the "Group Multiple items for a single condition" item on fellow MVP
Cindy Meister's website at:

http://homepage.swissonline.ch/cindymeister/mergfaq1.htm#DBPic


Or take a look at the following Knowledge Base Article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;211303

or at:

http://cornell.veplan.net/article.aspx?&a=3815


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter Jamieson

Unfortunately, Skip record if... does not work the way you probably think it
works. It sounds as if it ought to skip 1 record on the basis of the
criteria you specify, but in fact it cancels the merge of the current "copy"
of the merge document, then starts processing a new "copy" of the document
with the next record. So for example if you have 3 labels per page, and a
test in each label that says { SKIPIF { MERGEFIELD number } > 1 }, and
records as follows
number
1
1
2
1
1
2
1
1
2

You actually get no output (in fact in Word 2007 at least, you will see an
error message as well).

What you really need to make things work in this situation is a data source
that has exactly the same number of rows for every label. Easier said than
done, of course. However, one way you can create such a source is to do a
Directory (Catalog) merge to a new document, adding in rows where necessary.
Then you use that document as the data source for your label merge.

As a very simple example, suppose you have two columns of comma-delimited
data like this:

number,text
1,text1
2,text2
2,text3
3,text4
3,text5
3,text6
4,text6
4,text8
4,text9
4,text10
5,text11

and for the purposes of your merge you need 4 rows for each number, i.e.
this:

number,text
1,text1
,
,
,
2,text2
2,text3
,
,
3,text4
3,text5
3,text6
,
4,text6
4,text8
4,text9
4,text10
5,text11
,
,
,


Then you can create a Directory mail merge main document like this:

{ IF { MERGESEQ } = 1 "{ SET x -1 }{ SET count 4 }number,text
" }{ IF { MERGEFIELD number } = { x }
"{ SET count { ={ count }+1 }"
"{ IF { count } < 4 ",
" }{ IF { count } < 3 ",
" }{ IF { count } < 2 ",
" }{ SET count 1 }" }{ MERGEFIELD number },{ MERGEFIELD text }{ SET x {
MERGEFIELD number } }

Make sure there is a paragraph mark after { SET count 4 }number,text and at
the end of the following lines

"{ IF { count } < 4 ",
" }{ IF { count } < 3 ",
" }{ IF { count } < 2 ",

Also, each pair of { } must be the special field code braces that you can
insert using ctrl-F9.

Merge that to a new document and use that as the daa source for your label
merge.

If your data contains delimiter characters such as ",", """ (i.e.
double-quote) and <enter> then this will not quite be enough. You can deal
with "," by changing all the commas in the above example to tab characters.
As long as you have 63 columns of data or fewer, you can deal with
double-quote characters in your data source in a couple of ways, but the
easiest is probably
a. select the output created by the above merge
b. use Word's convert text to table function to convert the entire output
into a table

If you have <enter> in your records maybe we can discuss that...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top