Problem querying SQL Server View as mail merge source

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Todd H

    Problem querying SQL Server View as mail merge source

    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
  • Pieter Linden

    #2
    Re: Problem querying SQL Server View as mail merge source

    todholt@hotmail .com (Todd H) wrote in message news:<68a3516f. 0409071411.ffc2 655@posting.goo gle.com>...[color=blue]
    > Hi,
    >
    > I'm using the following code to perform a mail merge from an Access
    > project:
    >
    > With docMailMergeSou rce.MailMerge
    > .MainDocumentTy pe = wdFormLetters
    > .OpenDataSource 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'", _[/color]

    Try #9/1/01#

    Comment

    Working...