Word Merge Problem

  • Thread starter smcgrath via AccessMonster.com
  • Start date
S

smcgrath via AccessMonster.com

I found Kallal's Super Easy Word Merge and got it to work on my main form -
nor I would like to place a command button on my subform and have it merge
with that data - I found this code but I am a real novice at how to determine
what to do with it. Does the whole code go on the on click event of the
button?

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

This would be mine:
strMySql = "select" from NewDischargeQry where DischargeID = & me!DischargeID

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?
 
A

Albert D. Kallal

This would be mine:
strMySql = "select" from NewDischargeQry where DischargeID = &
me!DischargeID

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.

If the query does not include the parent fields, then obviously they will
not be included in the merge.

So, to fix this, then simply include fields from the main form (or child
form whichever is missing!!) into that query...
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?

Well, since the wordmerge buttion in on the child form now, you simply
restict the reocrd to the CHILD sub form's id.
strMySql = "select" from NewDischargeQry where childTable.ID = & me!id

I assume that me!ID is the current id of the current reocrd in the sub-form
(so, change the above childTable.ID to that actualy name/field you used in
the sub-form).

You can also still continue to have the buttion on the main form if you
wish, but sill restrict the sql to the ONE child reocrd.

eg:
strMySql = "select" from NewDischargeQry where childTable.ID = &
me.MySubForm.form!id

So, the simple answer is to run the merge from the sub-form, and use the
current sub-form id to restrict the sql to the ONE sub-form record (if you
include the parent record and fields in the sql query (via a join), then
those fields will also appear in the merge document.
 

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