Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Hi,
I am automating a mail merge from VS2008 using an exising MS Word 2008 document. The merge seems to work. The query returns the correct number of records and some of the fields are populated but not others. For the life of me I can't figure out why some fields aren't populated. The dates and numeric values work, but none of the text fields are populated. Thanks! Dim strSQL1, strSQL2 As String strSQL1 = "" strSQL2 = "" strSQL1 = "SELECT [Permit], [PermitDate], DateAdd(yyyy, 2, [PermitDate]) AS [ExpiryDate], [ExtDate], [Description], [Lot], [DistrictLot], [Plan], [Address], [Inspector], '250-492-0237' AS [InspectorPhoneNumber], " strSQL2 = "[Name], [Maddress], [MCity], [Mpostal], [Earea], [Folio], GetDate() AS [TodaysDate] FROM [permits] WHERE [Permit]0 AND [Active]=1 AND [FarmStatus]='N' AND [PermitDate]GetDate()-670 AND [PermitDate]GetDate()-730" ' Create an instance of Word and make it visible. Dim wrdApp As New Word.Application wrdApp = CreateObject("Word.Application") wrdApp.Visible = True ' Open document. Dim wrdDoc As Word.Document wrdDoc = wrdApp.Documents.Open("warning.docx") wrdDoc.MailMerge.OpenDataSource(Name:="", Connection:="DSN=Permits;DATABASE=Permits;uid=uid; pwd=pwd;", SQLStatement:=strSQL1, SQLStatement1:=strSQL2) wrdDoc.MailMerge.Execute() ' Release References. wrdDoc = Nothing wrdApp = Nothing |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Word 2007 - mail merge filter not displaying unique choices | Mailmerge | |||
Word 2007 Mail Merge Labels skips fields using update fields | Mailmerge | |||
Mail merge is displaying unwanted lines | Mailmerge | |||
Automated Mail Merge Displaying unwanted Dialog Boxes | Mailmerge | |||
MS Word form fields versus mail merge fields | Mailmerge |