Mail Merge from Query instead of Table

G

Guest

I'm creating a function designed to let a user create an invoice in Word 2003
by merging data from a parameter query in Access 2003. I have read articles
209976 and 214183. The example given suggests using a table as the source,
but I need a query to be the source since my needed data is stored in several
different tables. I wrote a function similar to the example using my query
instead of a table. Here's my function:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("Z:\Databeast\Databeast Appraisal Invoice
Template.doc", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="Z:\Databeast\Databeast Alpha.mdb", _
LinkToSource:=True, _
Connection:="QUERY [Invoice Query]", _
SQLStatement:="SELECT * FROM [Invoice Query]"
objWord.MailMerge.Execute
End Function

I attached this function to a command button. When I click the command
button, the Word document opens, but it asks me to select a Table from my
database instead of linking the document to my query. I can select the
correct query from the dialog box if I click the Options tab and check
"View". However, when I do this, Access tells me Word cannot open my data
source. I'd like for this function to open word, link to correct query, and
complete the merge. What do I need to fix?
 
G

Guest

Access 2003 made it very difficult (if not impossible) to link to a parameter
query. I did a work around where I created a make table query with the
parameter first then linked the Word merge to the new table. I don't know
much about vb so can't help with that I'm afraid but hope this helps

Sheila
www.c-i-m-s.com
MS Office training - London
 
G

Guest

Did that create a new table EVERY time you ran the query? If so, did you
delete the new tables each time?

My way around the problem so far has been to link the Word document to the
query myself and just have the command button open the Word file. The user
has to click through the merge process, but at least they don't have to rekey
any data.

Sheila D said:
Access 2003 made it very difficult (if not impossible) to link to a parameter
query. I did a work around where I created a make table query with the
parameter first then linked the Word merge to the new table. I don't know
much about vb so can't help with that I'm afraid but hope this helps

Sheila
www.c-i-m-s.com
MS Office training - London

wloftis said:
I'm creating a function designed to let a user create an invoice in Word 2003
by merging data from a parameter query in Access 2003. I have read articles
209976 and 214183. The example given suggests using a table as the source,
but I need a query to be the source since my needed data is stored in several
different tables. I wrote a function similar to the example using my query
instead of a table. Here's my function:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("Z:\Databeast\Databeast Appraisal Invoice
Template.doc", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="Z:\Databeast\Databeast Alpha.mdb", _
LinkToSource:=True, _
Connection:="QUERY [Invoice Query]", _
SQLStatement:="SELECT * FROM [Invoice Query]"
objWord.MailMerge.Execute
End Function

I attached this function to a command button. When I click the command
button, the Word document opens, but it asks me to select a Table from my
database instead of linking the document to my query. I can select the
correct query from the dialog box if I click the Options tab and check
"View". However, when I do this, Access tells me Word cannot open my data
source. I'd like for this function to open word, link to correct query, and
complete the merge. What do I need to fix?
 
G

Guest

I downloaded this...I'll let you know if I can get it to solve my problem -
thanks for the tip!

Iona said:
Hi, i'm a real gumby at this, however there is a really good query by
form you can download at:
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane

it also has a word mail merge feature for the query output.

cheers



I'm creating a function designed to let a user create an invoice in Word 2003
by merging data from a parameter query in Access 2003. I have read articles
209976 and 214183. The example given suggests using a table as the source,
but I need a query to be the source since my needed data is stored in several
different tables. I wrote a function similar to the example using my query
instead of a table. Here's my function:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("Z:\Databeast\Databeast Appraisal Invoice
Template.doc", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="Z:\Databeast\Databeast Alpha.mdb", _
LinkToSource:=True, _
Connection:="QUERY [Invoice Query]", _
SQLStatement:="SELECT * FROM [Invoice Query]"
objWord.MailMerge.Execute
End Function

I attached this function to a command button. When I click the command
button, the Word document opens, but it asks me to select a Table from my
database instead of linking the document to my query. I can select the
correct query from the dialog box if I click the Options tab and check
"View". However, when I do this, Access tells me Word cannot open my data
source. I'd like for this function to open word, link to correct query, and
complete the merge. What do I need to fix?
 
G

Guest

A make table query creates the table and each time you run the query it
deletes and re-creates the information so you only have 1 table

wloftis said:
Did that create a new table EVERY time you ran the query? If so, did you
delete the new tables each time?

My way around the problem so far has been to link the Word document to the
query myself and just have the command button open the Word file. The user
has to click through the merge process, but at least they don't have to rekey
any data.

Sheila D said:
Access 2003 made it very difficult (if not impossible) to link to a parameter
query. I did a work around where I created a make table query with the
parameter first then linked the Word merge to the new table. I don't know
much about vb so can't help with that I'm afraid but hope this helps

Sheila
www.c-i-m-s.com
MS Office training - London

wloftis said:
I'm creating a function designed to let a user create an invoice in Word 2003
by merging data from a parameter query in Access 2003. I have read articles
209976 and 214183. The example given suggests using a table as the source,
but I need a query to be the source since my needed data is stored in several
different tables. I wrote a function similar to the example using my query
instead of a table. Here's my function:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("Z:\Databeast\Databeast Appraisal Invoice
Template.doc", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="Z:\Databeast\Databeast Alpha.mdb", _
LinkToSource:=True, _
Connection:="QUERY [Invoice Query]", _
SQLStatement:="SELECT * FROM [Invoice Query]"
objWord.MailMerge.Execute
End Function

I attached this function to a command button. When I click the command
button, the Word document opens, but it asks me to select a Table from my
database instead of linking the document to my query. I can select the
correct query from the dialog box if I click the Options tab and check
"View". However, when I do this, Access tells me Word cannot open my data
source. I'd like for this function to open word, link to correct query, and
complete the merge. What do I need to fix?
 

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