View Single Post
  #2  
Old May 5th, 2004, 08:40 AM
Cindy M -WordMVP-
external usenet poster
 
Posts: n/a
Default Restrict records that match date criteria at merge time

Hi Peter,

Im trying to prepare a standard letter that uses fields
from a database via ODBC and Microsoft SQL. At merge
time, what is the easiest way for the office secretaty to
restrict the output letters between two dates? Is it
possible to embed dialog boxes that would appear at merge
time?

Filtering using dates in mail merge is a tricky proposition;
the dialog box way, then adjusting the QueryString property,
is probably the "safest" way.

The basic approach I'd consider:

1. Use a macro named AutoNew (will execute when a new doc is
created from a template)

2. Have it display a UserForm (dialog box) with two text
boxes for the dates.

3. The code behind the "OK" button would check the dates for
validity (IsDate), then adapt the
ActiveDocument.MailMerge.DataSource.QueryString property.
Exactly how you want to do that will depend on whether it
previously has been modified in any way, or whether you can
write it from scratch, but the syntax is standard SQL for
the type of datasource you're using.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)