View Single Post
  #1  
Old April 24th, 2004, 10:08 AM
Cindy M -WordMVP-
external usenet poster
 
Posts: n/a
Default Mail Merge Disable Choose Data Source

Hi Mariatherp,

I have set up a merge filter. If there is no data meeting the criteria
the users will receive this message:

"Word could not merge the main document with the data source because
the data records were empty or no data records matched your query
options." At this point I would like a msg box to come up "goodbye" and
close word. But Word allows the user to choose a new data source.

You'd have to handle all of this through a macro (VBA). Once you have the
merge filter defined in SQL syntax, don't send it to Word's .QueryString
property immediately.

Instead, use ADO or DAO to connect to the same data source, using this
SQL. Check the number of records in the recordset, and if it's 0, display
the message you wish. If it's 0, go ahead and do the Word stuff.

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