By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Problem querying SQL Server View as mail merge source

P: n/a
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=d eveloper;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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
to*****@hotmail.com (Todd H) wrote in message news:<68*************************@posting.google.c om>...
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'", _


Try #9/1/01#
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.