471,859 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,859 software developers and data experts.

merging multiple fields from various tables in one word document

I have posed a question last saturday and have advanced alot in the
meantime. But I am still not there

Problem is that I try to merging various fields from various tables in
one document in Word

1. Query..I want to keep the fields seperatred. I do not want to sent
on field with all accumulated languages from one person to Word. Each
language should appear in the document in a separate cell
Cross tables are not delivering the result I want. I get totals from
fields and get the feeling that it is more for mathematical purposes
2. I am now trying to solve it in VBA. I manage to open an existing
doc file (that would be my template with the merging fields). When I
start calling the first table in VBA to merge into the word document,
I get errors. These errrors are occuring due to the fact that the word
file also contains fields from 6 other tables that will be called for
in the VBA structure at a later stage.

so basically I do not manage to merge more than one table without
getting problems.

VBA code is enclosed

Private Sub Command90_Click()
On Error GoTo Err_Command90_Click

Dim objWord As Word.Document
Set objWord = GetObject("C:\Doc1.doc", "Word.Document")

' Make Word visible.
objWord.Application.Visible = True

' Set the mail merge data source as the CV database.
objWord.MailMerge.OpenDataSource _
Name:="S:\Access\actuele versie van cvs.mdb", _
LinkToSource:=True, _
Connection:="TABLE personalia", _
SQLStatement:="SELECT personalia.*, personalia.[reference
number] FROM personalia WHERE personalia.[reference number]=16"
'here I try to call the second table
'bjWord.MailMerge.OpenDataSource _
'Name:="S:\Access\actuele versie van cvs.mdb", _
'LinkToSource:=True, _
'Connection:="TABLE tbl_language", _
'SQLStatement:="Select * from [tbl_language]"

' Execute the mail merge.

Exit Sub

MsgBox Err.Description
Resume Exit_Command90_Click

End Sub

On the moment that I try to include the fields from the second table
in the word template it goes wrong. Word starts correcting all these
fields from the second table during the merging operation of the first
table. It does simply not recognize the fields from the second table

How to overcome this????

I have the feeling that queries are not possible with my structure
....I have enclosed my earleir question that would explain why it is
not possible

--------question from saturday
have been looking at a problem the entire week in access, I have
still not been able to find a solution. Hope that you could maybe tell
where to look

Concerns the link between Access and Word. I can not transfer a report
to word without losing out on the lay-out (RTF format). I understand
that there is no way out
ok, mail merge I thought. But here I have the problem that I need to
merge multiple tables and that I can just include one in the mailmerge
within word. A query would seem likely but there I have a problem. I
have one master table containing personal information on staff and 8
subtables around the master table with specifying language, workexp,
education for each person. The number of entries in the subtables
varies per person.

In case I use a query to combine all these tables I get # x # x # x #
x# (9 times) number of records an extreme number of records for each
An example: person A
knows 8 languages
has 3 educational references
10 publications
took 8 courses in his career
This would already result in 1 X 8 X 10 X 8 = 640 records
Do I miss a certain function with queries or how can I work this out?
can not imagine that it is not possible

Thanks and wishing you a good day
Stefan van den Hark
The Netherlands
Nov 13 '05 #1
1 4709
And what if you do a UNION with those tables? Say

select language, "language" from tblLanguages where
personalia.[reference number]=16
UNION select reference, "reference" from tblReferences where
personalia.[reference number]=16


Bas Cost Budde, Holland
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by dskillingstad | last post: by
4 posts views Thread by lesperancer | last post: by
reply views Thread by =?Utf-8?B?QmFkaXM=?= | last post: by
9 posts views Thread by karenjfrancis | last post: by
reply views Thread by NeoPa | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.