O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

15.4. Exchanging Information with Microsoft Word

Access has some wonderful reporting features. You can sort, group, filter, and even perform sophisticated combinations of those operations using VBA. If you can create such sophisticated reports in Access would you even need Word? Well, the simple answer is yes. There are a number of tasks you can't perform in Access and still others that you might simply want to transfer into Microsoft Word. For example, the first code sample we'll build starts a mail merge within Word from your Access data. While you can create a letter within Access, it must be done by someone with adequate permissions on your database. You probably don't want to give every user of your application permissions to create and modify reports. Many users probably have no desire to ever modify a report. Working around this limitation is pretty simple. Provide your users with a boilerplate mail merge document in Word and allow them to customize the mail merge document to suit their needs. Then they can simply initiate the mail merge from within Access.

Figure 15.8. Figure 15-8

You can write the mail merge code in two ways. The first, and simplest way, is to use Access VBA to simply define your data source and open the merge document. The second way is to use VBA to perform every step of the mail merge process. We'll examine both methods in this section.

15.4.1. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required