Hi,
I'm using the following code to perform a mail merge from an Access
project:
With docMailMergeSou rce.MailMerge
..MainDocumentT ype = wdFormLetters
..OpenDataSourc e Name:=<datasour ce path>, _
Format:=wdOpenF ormatAuto, ReadOnly:=True, LinkToSource:=F alse, _
ConfirmConversi ons:=False, _
SQLStatement:=" SELECT * FROM dbo.WelcomeLett erMailMerge_V WHERE
AgreementDate >= 'Sep 1, 2001'", _
Connection:="DR IVER=SQLServer; SERVER=SOMESVR; UID=developer;P WD=;APP=Microso ft
Data Access Components"
..Destination = wdSendToNewDocu ment
..Execute
..MainDocumentT ype = wdNotAMergeDocu ment
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.WelcomeLett erMailMerge_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 docMailMergeSou rce.MailMerge
..MainDocumentT ype = wdFormLetters
..OpenDataSourc e Name:=<datasour ce path>, _
Format:=wdOpenF ormatAuto, ReadOnly:=True, LinkToSource:=F alse, _
ConfirmConversi ons:=False, _
SQLStatement:=" SELECT * FROM dbo.WelcomeLett erMailMerge_V WHERE
AgreementDate >= 'Sep 1, 2001'", _
Connection:="DR IVER=SQLServer; SERVER=SOMESVR; UID=developer;P WD=;APP=Microso ft
Data Access Components"
..Destination = wdSendToNewDocu ment
..Execute
..MainDocumentT ype = wdNotAMergeDocu ment
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.WelcomeLett erMailMerge_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
Comment