Word Mail Merge with a Table

T

Tony_VBACoder

How can I get a Mail Merge Word Document to display data
in a Table where the data comes from an Access database?

I have a Word Mail Merge Letter that has the following
sample format with the following Merge Fields from an
Access Database Query that has all the data needed for
this letter. My sample Merge Fields are within the < >
characters:

+++ Sample Letter below +++++++++++++++++++++++++++

<First Name> <Last Name>
<Mailing Address>
<City> <ST> <ZipCode>

Dear <Saluation>:

The following items are in your order:

**** Here I want to add a Table with their orders ****
Order # Order Date Desc Amt Total
------- ---------- ---- --- -----
11111 4/1/2004 X 3 10
22222 5/1/2004 Y 5 20
33333 6/1/2004 Z 7 30

Thank you for your order.


++++++++++++++++++++++++++++++++++++++++++++++++++++

Does anyone have any idea if this can be done? I can do
this within Access, but wanted to know if this can be done
within Word 2000/2002? This would be similar to creating
a Main Report with a Sub Report containing the Orders,
within Access.
 
P

Peter Jamieson

It's simpler using Access reporting (I am told!) Word is not really set up
to do this. You can try using a DATABASE field to insert the table, using a
nested { MERGEFIELD } field to filter the results so that you only get the
items belonging to the current order. But it's very difficult to control the
format of tables inserted using DATABASE.

If you are using Word 2002 or 2003, the "official" way to do many things
that the built-in merge can't manage is to use VBA and the Mailmerge events.
This lets you modify the Mail Merge Main document before each record is
merged. So you could, for example, use VBA and ADO to get the appropriate
data from the database, insert it in tabular format and format it. However,
once you have gone that far, it may be simpler to "roll your own" merge,
using Word Automation to process the data from each order in turn and insert
it in the correct places in a fresh copy of your "mail merge" template.
 
T

Tony_VBACoder

Peter, that is what I thought. I may just go ahead and
keep this an Access report, because I can code the report
in about 10 minutes, whereas, it would be much more
difficult in Word.

Thanks.
 

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