Problem querying SQL Server View as mail merge source

D

Debbie

Well, it depends on how the date is formatted in your
table. My format is usually __/__/__, so the criteria
will show up in the SQL statement as follows:

((yourdatefield)="1/1/04")

If it's as text and believe me I've seen it done, you
would need to make sure that how you type it is exactly
how it is in the database. In order to get a parameter
value window open to choose what dates you want I usually
just put [Date] or Between [StartDate] and [End Date] in
the criteria field.

If you are worried about how your date will look in your
merge fields once merged into Word, here's a tip.
{MERGEFIELD YOURDATEFIELD \@ "MMMM d, yyyy"}
How to add this formatting to your Word Doc, hit Alt + F9.

-----Original Message-----
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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top