More on Word Merge

P

Phil

Hi,

I have the following function in a module. In this function the
"Connection" is to an access TABLE. Is it possile to connect to a query
which is using two tables? If so, how would the function be changed? Would
the "TABLE" in the connection statement be changed to "QUERY" with the query
name? How would one reference the fields in the query for the SQLStatement:?


I have no idea if this can be done.
Thanks a lot....
Phil



Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("MyMerge.doc", "Word.Document")

' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as Mailing List.

objWord.MailMerge.OpenDataSource _
Name:="Mailing List.mdb", _
LinkToSource:=True, _
Connection:="TABLE Mailing List", _
SQLStatement:="SELECT Last_Name, First_Name FROM [Mailing List] WHERE
[Mailing List].[Current Membership Date] > " & Format(Forms![Report
Menu]![Event_Start_Date], "\#mm\/dd\/yyyy\#") & ""

' Execute the mail merge.
objWord.MailMerge.Execute
End Function
 

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