I have the following code for mail merge..It seems to be working, but even though I have the sql in the sql statement, it is still popping up a few things, which I need to avoid..
one is a window with a list of tables from the database to select from, even though I am already defining the sql statement in the code below..
The the other one is Microsoft Word Document with Yes/No buttons:
Opening this document will run the following SQL Command:
Select * from '00005067'
Data from your database will be placed in the document. Do you want to continue?
I am even setting the display errors to none. It is happenning inspite of that. More than this the select list is more annoying because there will be a huge list of tables displayed which I want to avoid.
Any help from you will be greatly appreciated. Thank you for your help in advance.
Function MergeIt(fsHistoryId As String, fsTemplateId As String)
Dim objWord As Word.Document
Dim lsSql As String
lsSql = "Select * from " & [fsTemplateId] & " where historyId = " & fsHistoryId
Set objWord = GetObject("H:\RDA\ITS\MailMerge\" & fsTemplateId & ".doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
objWord.Application.DisplayAlerts = wdAlertsNone
' Set the mail merge data source as the Northwind database.
Name:= CurrentDb.name, _
Connection:="TABLE " & [fsTemplateId], _
' Execute the mail merge.