Consulting

Results 1 to 4 of 4

Thread: Solved: error-handling in automated mail merge

  1. #1
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location

    Question Solved: error-handling in automated mail merge

    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>>
    With program specs this fickle, you've just got to believe in Discord.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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

  3. #3
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location
    Quote Originally Posted by mdmackillop
    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!
    With program specs this fickle, you've just got to believe in Discord.

  4. #4
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location
    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!
    With program specs this fickle, you've just got to believe in Discord.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •