Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
MMbosman MMbosman is offline
external usenet poster
 
Posts: 3
Default Mail Merge with DB to create a table of related records

I have a list of divisions that have vehicles assigned in each division. I
need to create a mail merge in Word 2003 that creates a single document per
division with a listing of each vehicle in the division. The number of
vehicles changes based on the division.

The mail merge is not a problem, but how can I link a database query to
populate a table to the mail merge field for each division? This is giving me
fits, but there must be an easy way to do this that I am overlooking.


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail Merge with DB to create a table of related records

Word isn't particularly well set up to do this (if possible, use another
reporting tool that is, such as Access reporting), but what you do is
a. use the division list as the data source for the merge
b. enable the Database toolbar in Word (e.g. Tools|Customize)
c. use that to insert the databse of vehicles /as a field/ you then have
something like

{ DATABASE \d "your database file, if it's a .mdb, or a .odc file, if it's a
SQL Server table"
\c "a whole bunch of connection information"
\s "SELECT * FROM [Vehicles]" \h }

Use Alt-F9 to look at the field code, and manually alter the SELECT field so
it coordinates with the Division, e.g. if you have a numeric DivisionID as a
foeign key in your Vehicles table, and your Division table also has a field
"DivisionID" field, you will need something like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = { MERGEFIELD DivisionID }"
\h

If the DivisionID is alphanumeric, you would need something more like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = '{ MERGEFIELD DivisionID }'"
\h

/All/ the {} need to be the special field codes you can insert using
ctrl-F9. You may also find that Word does not recognise apparently correct
SQL syntax and requires you to alias the table name, e.g.

\s "SELECT v." FROM [Vehicles] v WHERE v.DivisionID = { MERGEFIELD
DivisionID }" \h

Peter Jamieson

"MMbosman" wrote in message
...
I have a list of divisions that have vehicles assigned in each division. I
need to create a mail merge in Word 2003 that creates a single document
per
division with a listing of each vehicle in the division. The number of
vehicles changes based on the division.

The mail merge is not a problem, but how can I link a database query to
populate a table to the mail merge field for each division? This is giving
me
fits, but there must be an easy way to do this that I am overlooking.



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
MMbosman MMbosman is offline
external usenet poster
 
Posts: 3
Default Mail Merge with DB to create a table of related records

First off thanks for the speedy reply. I've attempted to make this work, but
without success. My data source in this instance is an excel sheet. I can
edit the query and enter a number for the division and that is successful but
when using the MERGEFIELD as the link between the merge and the database it
isn't working. I'll keep fiddling. Thanks again.

"Peter Jamieson" wrote:

Word isn't particularly well set up to do this (if possible, use another
reporting tool that is, such as Access reporting), but what you do is
a. use the division list as the data source for the merge
b. enable the Database toolbar in Word (e.g. Tools|Customize)
c. use that to insert the databse of vehicles /as a field/ you then have
something like

{ DATABASE \d "your database file, if it's a .mdb, or a .odc file, if it's a
SQL Server table"
\c "a whole bunch of connection information"
\s "SELECT * FROM [Vehicles]" \h }

Use Alt-F9 to look at the field code, and manually alter the SELECT field so
it coordinates with the Division, e.g. if you have a numeric DivisionID as a
foeign key in your Vehicles table, and your Division table also has a field
"DivisionID" field, you will need something like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = { MERGEFIELD DivisionID }"
\h

If the DivisionID is alphanumeric, you would need something more like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = '{ MERGEFIELD DivisionID }'"
\h

/All/ the {} need to be the special field codes you can insert using
ctrl-F9. You may also find that Word does not recognise apparently correct
SQL syntax and requires you to alias the table name, e.g.

\s "SELECT v." FROM [Vehicles] v WHERE v.DivisionID = { MERGEFIELD
DivisionID }" \h

Peter Jamieson

"MMbosman" wrote in message
...
I have a list of divisions that have vehicles assigned in each division. I
need to create a mail merge in Word 2003 that creates a single document
per
division with a listing of each vehicle in the division. The number of
vehicles changes based on the division.

The mail merge is not a problem, but how can I link a database query to
populate a table to the mail merge field for each division? This is giving
me
fits, but there must be an easy way to do this that I am overlooking.




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail Merge with DB to create a table of related records

My best guess in this case is that you are seeing error messages because
your data source is already open and you are trying to use the same .xls as
the source for the DATABASE field. But I can't be sure. What error message
(or other evidence of failure) are you seeing?

Peter Jamieson
"MMbosman" wrote in message
...
First off thanks for the speedy reply. I've attempted to make this work,
but
without success. My data source in this instance is an excel sheet. I can
edit the query and enter a number for the division and that is successful
but
when using the MERGEFIELD as the link between the merge and the database
it
isn't working. I'll keep fiddling. Thanks again.

"Peter Jamieson" wrote:

Word isn't particularly well set up to do this (if possible, use another
reporting tool that is, such as Access reporting), but what you do is
a. use the division list as the data source for the merge
b. enable the Database toolbar in Word (e.g. Tools|Customize)
c. use that to insert the databse of vehicles /as a field/ you then have
something like

{ DATABASE \d "your database file, if it's a .mdb, or a .odc file, if
it's a
SQL Server table"
\c "a whole bunch of connection information"
\s "SELECT * FROM [Vehicles]" \h }

Use Alt-F9 to look at the field code, and manually alter the SELECT field
so
it coordinates with the Division, e.g. if you have a numeric DivisionID
as a
foeign key in your Vehicles table, and your Division table also has a
field
"DivisionID" field, you will need something like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = { MERGEFIELD
DivisionID }"
\h

If the DivisionID is alphanumeric, you would need something more like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = '{ MERGEFIELD
DivisionID }'"
\h

/All/ the {} need to be the special field codes you can insert using
ctrl-F9. You may also find that Word does not recognise apparently
correct
SQL syntax and requires you to alias the table name, e.g.

\s "SELECT v." FROM [Vehicles] v WHERE v.DivisionID = { MERGEFIELD
DivisionID }" \h

Peter Jamieson

"MMbosman" wrote in message
...
I have a list of divisions that have vehicles assigned in each division.
I
need to create a mail merge in Word 2003 that creates a single document
per
division with a listing of each vehicle in the division. The number of
vehicles changes based on the division.

The mail merge is not a problem, but how can I link a database query to
populate a table to the mail merge field for each division? This is
giving
me
fits, but there must be an easy way to do this that I am overlooking.





  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
MMbosman MMbosman is offline
external usenet poster
 
Posts: 3
Default Mail Merge with DB to create a table of related records

Actually I didn't fully qualify the sheet name with `Sheet1$`.Division that
was my problem. Thanks for your help, but I have one last question.

Now that it is hooked up to each data source is it possible to set something
to force the table filled by the database to refresh itself without having to
press the refresh button - sort of the same way a report and sub report work
in access?

"Peter Jamieson" wrote:

My best guess in this case is that you are seeing error messages because
your data source is already open and you are trying to use the same .xls as
the source for the DATABASE field. But I can't be sure. What error message
(or other evidence of failure) are you seeing?

Peter Jamieson
"MMbosman" wrote in message
...
First off thanks for the speedy reply. I've attempted to make this work,
but
without success. My data source in this instance is an excel sheet. I can
edit the query and enter a number for the division and that is successful
but
when using the MERGEFIELD as the link between the merge and the database
it
isn't working. I'll keep fiddling. Thanks again.

"Peter Jamieson" wrote:

Word isn't particularly well set up to do this (if possible, use another
reporting tool that is, such as Access reporting), but what you do is
a. use the division list as the data source for the merge
b. enable the Database toolbar in Word (e.g. Tools|Customize)
c. use that to insert the databse of vehicles /as a field/ you then have
something like

{ DATABASE \d "your database file, if it's a .mdb, or a .odc file, if
it's a
SQL Server table"
\c "a whole bunch of connection information"
\s "SELECT * FROM [Vehicles]" \h }

Use Alt-F9 to look at the field code, and manually alter the SELECT field
so
it coordinates with the Division, e.g. if you have a numeric DivisionID
as a
foeign key in your Vehicles table, and your Division table also has a
field
"DivisionID" field, you will need something like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = { MERGEFIELD
DivisionID }"
\h

If the DivisionID is alphanumeric, you would need something more like

\s "SELECT " FROM [Vehicles] WHERE DivisionID = '{ MERGEFIELD
DivisionID }'"
\h

/All/ the {} need to be the special field codes you can insert using
ctrl-F9. You may also find that Word does not recognise apparently
correct
SQL syntax and requires you to alias the table name, e.g.

\s "SELECT v." FROM [Vehicles] v WHERE v.DivisionID = { MERGEFIELD
DivisionID }" \h

Peter Jamieson

"MMbosman" wrote in message
...
I have a list of divisions that have vehicles assigned in each division.
I
need to create a mail merge in Word 2003 that creates a single document
per
division with a listing of each vehicle in the division. The number of
vehicles changes based on the division.

The mail merge is not a problem, but how can I link a database query to
populate a table to the mail merge field for each division? This is
giving
me
fits, but there must be an easy way to do this that I am overlooking.






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Related items from different records on one page CAI Tech Guy Mailmerge 2 September 14th 06 01:47 PM
merge related records onto a page w/new page at defined data Pamrus Mailmerge 1 April 1st 06 07:01 AM
Mail Merge does not include all records from list or Access table Paul Fahey Mailmerge 0 March 27th 06 12:08 AM
Mail Merge does not include all records from list or Access table Doug Robbins - Word MVP Mailmerge 0 March 26th 06 11:54 PM
Add related subform to mail merge document Carolyn M Mailmerge 2 March 19th 06 12:29 PM


All times are GMT +1. The time now is 03:47 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"