Restrict records that match date criteria at merge time

P

Peter Wilde

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? Any suggestions?
 
C

Cindy M -WordMVP-

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
:)
 

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