View Single Post
  #2  
Old October 5th, 2006, 09:02 PM posted to microsoft.public.access.forms
Albert D. Kallal
external usenet poster
 
Posts: 2,874
Default Super Easy Word Merge onto multiple tables?

I tried Wayne's suggestion and created a query incorporating all the
fields
that I would want to use in the various document templates and then
created a
form based on that Query.
That worked fine on its own.



But when I added that as a subform into one of
the other pages,


What do you mean by "added that"??? Why are you adding ANYTHING to a
sub-form? The suggestion was to use a query that pulls in all of those
fields that you need.

You can then specify the query for a merge in palce of the merge
automatilcay using the current form filds.

(RTFM) - here
http://www.members.shaw.ca/AlbertKal...rge/page2.html


eg:

dim strMySql as string

strMySql = "select * from MyWayCoolQueryWithAllFields where id = " & me!id

MergeAllWord strMySql

So, continue to launch the merge from the main form, but just use that query
you built with all of the other fields included. when you do the above, the
query with all of the extra fields will be available in the merge...

I suppose if you wanted to, you could base the form on that huge query also,
but I don't think that makes sense, and the above is only one extra line of
code anyway....

The only problem I see here is "WHICH CHILD record" do you want to choose in
these cases. (or, are all of the sub-forms (child tables) always only one
record?).

If you need to restrict the merge to a particular sub-form record, then
place the merge button on that sub-form, and go:

dim strMySql as string

strMySql = "select * from MyWayCoolQueryWithAllFields where ChildID = " &
me!ChildID

MergeAllWord strMySql

So, the above sql string would restrict the query to the ONE child record.
But, of course that child record will still include all of the main forms
fields. I don't think I saw your other post, but you not explained *how* you
plan to choose (select) which child record to be included in the merge?

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada