I have 2 tables, Customers and Information linked by a common field Linknumber.
They both have a form. Customers is the main form, and Information is a sub form of Customers.
A query called Blended Query takes the data from both tables
On the sub form is a Command button that starts a Macro.
The Macro calls the Function below which creates a Mailmerge for each customer in Word .
Function MergeIt1()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\ My Documents\Ron\ Database\Rental.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Bollo database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\My Documents\Ron\ Database\Bollo.mdb", _
LinkToSource:=True, _
Connection:="QUERY blended query", _
SQLStatement:="SELECT * FROM [blended query]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function
I would like to restrict the data in the query to that of the open Form only, so that the mail merge creates only for that customer.
Also is there any way of stopping the warning message in Word when the SQL statement is about to run. It requires a Yes or No choice to be made.
They both have a form. Customers is the main form, and Information is a sub form of Customers.
A query called Blended Query takes the data from both tables
On the sub form is a Command button that starts a Macro.
The Macro calls the Function below which creates a Mailmerge for each customer in Word .
Function MergeIt1()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\ My Documents\Ron\ Database\Rental.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Bollo database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\My Documents\Ron\ Database\Bollo.mdb", _
LinkToSource:=True, _
Connection:="QUERY blended query", _
SQLStatement:="SELECT * FROM [blended query]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function
I would like to restrict the data in the query to that of the open Form only, so that the mail merge creates only for that customer.
Also is there any way of stopping the warning message in Word when the SQL statement is about to run. It requires a Yes or No choice to be made.