Albert Kallal Mail Merge from a query

T

Twb

I am using Albert Kallal's mail merge to merge data from my database to a
letter in Word. The problem is that the merge fields come from a sub form.
When I click on the button on my form to run the mail merge, the mail merge
letter open’s but the “Invalid Merge Field†window open’s and highlight all
the fileds from the imbedded form. When I check the data source only the
fields for the main form is listed.

how can i get it to use all the files from the subform?
 
A

Albert D. Kallal

Twb said:
I am using Albert Kallal's mail merge to merge data from my database to a
letter in Word. The problem is that the merge fields come from a sub form.
When I click on the button on my form to run the mail merge, the mail
merge
letter open's but the "Invalid Merge Field" window open's and highlight
all
the fileds from the imbedded form. When I check the data source only the
fields for the main form is listed.

how can i get it to use all the files from the subform?

You can get the merge to use the fields from the sub form IF you build a
query that joins the two tables.

Then, for the merge go:

dim strSql as string
me.refresh
strSql = "select * from yourQueryGoesHere where id = & me!id
MergeAllWord

note that you still only get one row of data for the merge, but it will
include the child fields now.

If you want the above to ONLY merge one row from the sub-form, then you can
go:

strSql = "select * from yourQueryGoesHere where subFormName.id = &
me.mySubForm.form!ID

My Merge sample is based on and uses the built in word merge, so you can't
really merge many rows into one document. if your requirement is to have one
main record, and many child records merge into one document, then I would
suggest you build the report and export that to word. Even better would be
to consider exporting the report as a pdf document.

If the above work around are not what you need, and you really want a put in
the multiple rows of data into the one word document, then there's some
samples here and how to do this:

http://homepage.swissonline.ch/cindymeister/MergFram.htm

look on the left side for special merges. The one you want is

Multiple items per condition
 

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

Similar Threads


Top