creating numbered lists from datasource

B

Bosconian

This seems like it should be easy, but I can't seem to find the answer.

I need to create a numbered list in Word from a datasource containing a
dynamic number of rows.

For example:

1. Paragraph text #1

2. Paragraph text #2

3. Paragraph text #3

How do you loop through a recordset using the same merge fields?

I've tried

{ MERGEFIELD ParagraphText }{ Next Record }

but this will only output the first record. I need a 'goto' type function to
loop through all the records.

Thanks in advance.
 
B

Bosconian

Bosconian said:
This seems like it should be easy, but I can't seem to find the answer.

I need to create a numbered list in Word from a datasource containing a
dynamic number of rows.

For example:

1. Paragraph text #1

2. Paragraph text #2

3. Paragraph text #3

How do you loop through a recordset using the same merge fields?

I've tried

{ MERGEFIELD ParagraphText }{ Next Record }

but this will only output the first record. I need a 'goto' type function
to loop through all the records.

Thanks in advance.

After some additional investigating, I have concluded that Word (2K) doesn't
have a built-in way to loop through a record set using the same merge field.
So you'll need to hardcode the maximum number of items your template is
expected to include.

So, the easiest way to accomplish this is by doing something like the
following:

{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }" ""}{
NEXT }

If you want each item numbered, simply highlight the merge field (the output
portion, not the condition) and choose your preferred number format via
Format->Bullets and Numbering. In this case the merge data display should
look like this:

{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }
1. " ""}{ NEXT }
{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }
2. " ""}{ NEXT }
{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }
3. " ""}{ NEXT }
{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }
4. " ""}{ NEXT }
{ IF {MERGEFIELD questiontext } <> "" "{MERGEFIELD questiontext }
5. " ""}{ NEXT }

Note the line break placement, which will be included in the output.

Happy merging.
 
D

Doug Robbins - Word MVP

You should use a catalog or directory type mailmerge main document.
However, 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

http://www.knowhow.com/Guides/CompoundMerges/CompoundMerge.htm

--
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
 

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