T
Todd H
Hi,
I'm using the following code to perform a mail merge from an Access
project:
With docMailMergeSource.MailMerge
..MainDocumentType = wdFormLetters
..OpenDataSource Name:=<datasource path>, _
Format:=wdOpenFormatAuto, ReadOnly:=True, LinkToSource:=False, _
ConfirmConversions:=False, _
SQLStatement:="SELECT * FROM dbo.WelcomeLetterMailMerge_V WHERE
AgreementDate >= 'Sep 1, 2001'", _
Connection:="DRIVER=SQLServer;SERVER=SOMESVR;UID=developer;PWD=;APP=Microsoft
Data Access Components"
..Destination = wdSendToNewDocument
..Execute
..MainDocumentType = wdNotAMergeDocument
End With
The problem I'm having is with the SQLStatement. As is, I get a word
is unable to open datasource error. If I change it to "SELECT * FROM
dbo.WelcomeLetterMailMerge_V WHERE 1=1", everything works fine, but I
don't have any date constraint. Am I representing the date in an
incorrect format? If I paste the query into Query Analyzer, it runs
just fine. I've tried using # marks, and double quotes to surround
the date, but haven't had any luck.
Any Suggestions?
Thanks,
Todd
I'm using the following code to perform a mail merge from an Access
project:
With docMailMergeSource.MailMerge
..MainDocumentType = wdFormLetters
..OpenDataSource Name:=<datasource path>, _
Format:=wdOpenFormatAuto, ReadOnly:=True, LinkToSource:=False, _
ConfirmConversions:=False, _
SQLStatement:="SELECT * FROM dbo.WelcomeLetterMailMerge_V WHERE
AgreementDate >= 'Sep 1, 2001'", _
Connection:="DRIVER=SQLServer;SERVER=SOMESVR;UID=developer;PWD=;APP=Microsoft
Data Access Components"
..Destination = wdSendToNewDocument
..Execute
..MainDocumentType = wdNotAMergeDocument
End With
The problem I'm having is with the SQLStatement. As is, I get a word
is unable to open datasource error. If I change it to "SELECT * FROM
dbo.WelcomeLetterMailMerge_V WHERE 1=1", everything works fine, but I
don't have any date constraint. Am I representing the date in an
incorrect format? If I paste the query into Query Analyzer, it runs
just fine. I've tried using # marks, and double quotes to surround
the date, but haven't had any luck.
Any Suggestions?
Thanks,
Todd