View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
projectmergeleader projectmergeleader is offline
external usenet poster
 
Posts: 11
Default SQL errors in mail merge

The table is formatted as such

Client; number; description

and the sql is counting the number of instances where client is equal to
Client but if there is no Client in the table it does not create the invoice
although the sql just returns 0.

S

"Peter Jamieson" wrote:

Is there a reason why you cannot write the SQL so that it always succeeds
(i.e. eliminates the clients with no invoices, or whatever it is that causes
the problem? Maybe you could provide the SQL and say exactly in what
circumstances the SQL fails?

Although you can control the course of the Merge to an extent using Word's
MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is
likely to be the one you need, but since Word itself is still fetching the
records, I don't think you will be able to trap errors in there or do a
try/catch that will catch this problem (probably worth a try though!)

--
Peter Jamieson
http://tips.pjmsn.me.uk

"projectmergeleader" wrote in
message ...
I am doing a mail merge project that counts the number of instances of a
client in a table. When it trys to count the number of instances for a
client
that is not present in the table then it does not produce the required
document. I guess this is because the sql command is throwing an error and
the document cannot handle it so it just skips the relevant invoice. Is
there
any sort of try/catch statement that can be used within word?

Thanks

S