Add 1 to count when printing document

N

Nick

I want to count the number of times I am sending out reminder notices.
To do this I want to add 1 to a field in my db, called nosent, every time I
print the mailmerged document, can anybody help.
 
P

Peter Jamieson

Word Mailmerge has no built-in facilities that let you update a data source,
so you would have to use a macro to do this. There are various approaches,
depending on the version of Word. In Word 2002 and 2003, you can use the
Events of the Mailmerge object to run a piece of code one time for each
record being merged. Suppose your data is in an Access table. Then your
event handler could use ADO to open another connection to the database, and
update the current record. Earlier versions of Word do not have these
events, so your macro might do the merge first, then iterate through tthe
records in the datasource (using the Mailmerge object) and use ADO to update
each record in turn. (Actually, in theory, you might be able to take the SQL
used to query the database and turn it into an UPDATE query that updated all
the affected records in one go, but I suspect going that route would be
asking for trouble).

You are likely to encounter at least three problems:
a. if for some reason, your merge fails but your update does not, your
counters will not be accurate (e.g. if you perform the merge but the printer
is out of paper and you have to cancel and restart).
b. some data sources will be easier to work with than others - for example,
you can use ADO or perhaps DAO to work with Access, SQL Server etc., but
things might be more difficult if your source is a Word document or a text
file
a. Depending on the data source and the connection type, you may not be
able to open a new connection to the data source while Word is performing
the merge.

Peter Jamieson
 

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