Insert text based on name of table?

J

John Williams

I have a mail merge document which I run separately with 2 data
sources (2 tables from the same Access database). The document has a
single word which changes depending on which data source table is
being used.

Obviously I can create 2 separate mail merge documents, however I
would like to have just one document with the single word included
depending on the name of the table.

Is it possible to insert text based on the name of the table that the
data is being selected from?

E.g. if the table is Cows, insert the mail merge text 'Milk'
and if the table is Sheep, insert the mail merge text 'Wool'.
 
C

Cindy M -WordMVP-

Hi John,
I have a mail merge document which I run separately with 2 data
sources (2 tables from the same Access database). The document has a
single word which changes depending on which data source table is
being used.

Obviously I can create 2 separate mail merge documents, however I
would like to have just one document with the single word included
depending on the name of the table.

Is it possible to insert text based on the name of the table that the
data is being selected from?
No, I'm afraid there's no functionality in Word that would let you do
this. Unless you'd use a macro. Then it could work. The exact macro
syntax would depend on the version of Word you're using, and the
connection method to the database.

Or, if the values in a particular field would reflect this, it could
work. I think you should be able to add a column to each query that
would evaluate to the same for each record. Then you could use an IF
field to test that column (field).

Open one of the queries, go to the first empty column in the Design
grid and type in this:
TableName: "Milk"

Now look at the query result.
E.g. if the table is Cows, insert the mail merge text 'Milk'
and if the table is Sheep, insert the mail merge text 'Wool'.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

John Williams

Cindy M -WordMVP- said:
Or, if the values in a particular field would reflect this, it could
work. I think you should be able to add a column to each query that
would evaluate to the same for each record. Then you could use an IF
field to test that column (field).

Open one of the queries, go to the first empty column in the Design
grid and type in this:
TableName: "Milk"

Now look at the query result.

Thank you Cindy. That works perfectly.
 

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