July 11, 2005 at 5:54 am
Just moving over from access to SQL. In my old access dB I had a mail merge to MS Word, I am now using a ADP as my front end can anyone help me in how i can get a mail merge to work in this format.
July 12, 2005 at 10:38 am
There are a number of ways to do this, but here is what I use for all my mail merges. This code is in the Word template and I happen to call it from a C# front-end but that is not required.
Sub RunMerge(strConnect As String, strParams As String)
Dim strSQL As String
strSQL = "exec dbo.rpt_Survey " & strParams
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
'* THIS WORKS WITH UDL or ODC FILE
.OpenDataSource Name:=strConnect, _
SQLStatement:=strSQL
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With
End Sub
strConnect can reference either a UDL or ODC file and would look something like:
strConnect = "E:\Projects\MyApp\templates\myApp.udl"
strSQl references a stored procedure that takes zero to n comma separated parameters. It is important that the parameter be prefixed with "exec dbo." as shown.
robert
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy