W
wloftis
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?
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?