PDA

View Full Version : Solved: error-handling in automated mail merge



eed
09-24-2004, 12:06 PM
Okay, so I have two procedures to automate some mail merges of Access data with Word templates. Both procedures work very smoothly -- when the database contains data for the user-specified parameters.

When the database does not contain the user-requested dataset, ONE procedure handles the errors very smoothly, and the other totally chokes, leaving MS Word (and the template file) in a state of disarray.

I created the second procedure by just copying and modifying the first, so I can't figure out where lies the discrepancy that is causing the different behaviors. I would like the second procedure to handle the errors smoothly and quietly the way the first procedure does.

A mostly stripped sample version of my database is attached; it should allow you to test and see if you observe the same differences in behavior that I did. Thanks in advance for any suggestions on how I can make the second procedure behave like the first!!

<<problem solved: attached db removed 9-27 for privacy concerns. --eed>>

mdmackillop
09-24-2004, 02:41 PM
Hi,
Maybe not the way you want to go, and I don't fully uderstand it all on a brief inspection, but I would do a CountRecords on the query that makes the DataSource. No records then Exit Sub, before the mailmerge runs.
MD

eed
09-27-2004, 05:40 AM
Hi,
Maybe not the way you want to go, and I don't fully uderstand it all on a brief inspection, but I would do a CountRecords on the query that makes the DataSource. No records then Exit Sub, before the mailmerge runs.
MD
That sounds brilliant. Why didn't I think to try that? I'll try it right away and post again regarding whether it accomplishes what I needed. Thanks!

eed
09-27-2004, 06:13 AM
Yup, that did the trick. Just catch the potential error of an empty recordset before you're already inextricably stuck in the middle of the mail merge. Still don't know why the two things were behaving differently, but that doesn't really matter, as long as I can catch the error cleanly and prevent the MS Word mess.

Thanks a bunch!