The first 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?
The next 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..
Is it possible to avoid these two prompts?
Any help from you will be greatly appreciated. Thank you for your help in advance.
Expand|Select|Wrap|Line Numbers
- 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
- ' Set the mail merge data source as the Northwind database.
- objWord.MailMerge.OpenDataSource _
- Name:= CurrentDb.name, _
- LinkToSource:=True, _
- Connection:="TABLE " & [fsTemplateId], _
- SQLStatement:=lsSql
- ' Execute the mail merge.
- objWord.MailMerge.Execute
- End Function