Using the Access Mail Merge Wizard

Access 2003's Mail Merge Wizard can help you create a new main merge document or employ an existing main merge document from which to create form letters. The Mail Merge Wizard uses a table or a query as the data source for the merge data file. The sections that follow describe two methods of creating a form letter:

  • Using the Mail Merge Wizard to create a new main merge document whose merge data source is a Jet table

  • Using an existing main merge document with a merge data source from a Jet table with a filter or a select query

graphics/access_2002_new_icon.gif

Access 2000 and earlier used Dynamic Data Exchange (DDE) to send mail merge data to Word. Access 2003 uses an OLE DB data source to generate mail-merge documents. OLE DB and Automation is a much more reliable method of interapplication communication than DDE. Using OLE DB also lets you take advantage of Word's filter and sort features, which were unavailable from documents created with earlier versions of the Mail Merge Wizard.

Creating and Previewing a New Form Letter

When you first try a new wizard, it's customary to create a new object rather than use the wizard to modify an existing object, such as a main merge document. The following steps use the Mail Merge Wizard to create a new main merge document from records in the Customers table of Northwind.mdb:

  1. graphics/mode.gif Open Northwind.mdb, if necessary, and select the Customers table in the Database window.

  2. Click the arrow beside the Office Links button to open the drop-down menu and select Merge It with Microsoft Word to launch the Microsoft Word Mail Merge Wizard.

  3. graphics/fom_letters.gif Select the Create a New Document and Then Link the Data to It option (see Figure 8.48) to create a new main merge document using fields from the Customers table.

    Figure 8.48. The Mail Merge Wizard's only dialog lets you use an existing merge document (the default) or create a new document.

    graphics/08fig48.jpg

  4. Click OK to launch Word 2003, if it isn't running. Word opens a new mail merge main document, Document1, and displays the Mail Merge page of the task pane.

  5. graphics/field_list.gif Click the Insert Merge Fields button to verify the available fields from the Customers table in the Insert Merge Field dialog, as shown in Figure 8.49. Click Cancel to close the dialog, and close the task pane.

    Figure 8.49. When you start the mail merge process, Word opens with the Mail Merge menu and task pane page active. The Insert Merge Field dialog confirms that you selected the correct table as the merge data source.

    graphics/08fig49.jpg

    Tip

    graphics/show_hide.gif

    Click the Show/Hide button on Word's toolbar to display end-of-paragraph marks. Choose Tools, Options, and mark the options on the View page to show space characters, tab characters, and other document symbols that are usually hidden. All figures of Word 2003 in these sections were captured with the Show/Hide button active.

  6. With the cursor at the top of the document, choose Insert, Date and Time to display the Date and Time dialog; choose any date format you want, mark the Update Automatically check box, and click OK to add a date field to the main document.

  7. graphics/field_list.gif Add two blank lines, click the Insert Merge Fields button to display the list, and double-click to insert the CompanyName, Address, City, Region, PostalCode, ContactName, and ContactTitle fields from the Customers table to create the address section of the main document. Format the field names, which insert in a single line in Word's Normal view, as shown in Figure 8.50.

    Figure 8.50. Arrange merge fields in letter format after you insert them.

    graphics/08fig50.jpg

  8. graphics/view_merged_data.gif Click the View Merged Data button of the Mail Merge toolbar to preview the appearance of the first of your form letters.

  9. graphics/find_entry.gif The form letters go only to customers in the United States, so you should check the address format for United States addresses. Click the Find Entry button on the toolbar to open the Find Entry dialog, type USA in the Find text box, and select Country from the This Field list. Click Find Next to find the first U.S. record. Alternatively, type 32 in the Go To Record text box of the toolbar, and press enter. The preview of the form letter for Great Lakes Food Market appears as shown in Figure 8.51.

    Figure 8.51. After clicking the View Merged Data toolbar button, use the Find Entry dialog to locate the record for the first U.S. customer.

    graphics/08fig51.jpg

  10. graphics/mail_merge.gif To send letters to U.S. customers only, click Word's Mail Merge Recipients button to open the eponymous dialog with the current record selected. Open the Country field's list and choose (Advanced...), as shown in Figure 8.52 to specify a Word filter on the Country field.

    Figure 8.52. Word 2003's Mail Merge Recipients dialog lets you choose how to filter and sort the data source for mail merge documents.

    graphics/08fig52.gif

  11. graphics/access_2002_new_icon.gif

    In the Filter dialog, select the Country field, if necessary, accept the default Equal To comparison, and type USA in the Compare To text box (see Figure 8.53). You can create complex filters by adding additional criteria and selecting And or Or to determine the filter logic. Click the Sort tab, select PostalCode in the Sort By list, and click OK to close the dialog.

    Figure 8.53. The Filter page of the Filter and Sort dialog lets you specify expressions and criteria on which to filter the data source.

    graphics/08fig53.gif

  12. Applying a filter marks for inclusion only those records that meet the filter criterion (see Figure 8.54). Click OK to close the dialog.

    Figure 8.54. The Wizard marks and sorts the set of filtered records in preparation for generating the mail-merge documents.

    graphics/08fig54.gif

  13. graphics/current_record.gif The filtered list is applied to the mail-merge document. Click the Next Record button to display only the U.S. records in sequence.

  14. graphics/merge_new_document.gif Click the Merge to New Document button to open the dialog of the same name. Accept the All (records) option, and click OK to generate the Letters1 document that contains the 13 letters to U.S. customers (see Figure 8.55).

    Figure 8.55. The merge document contains a letter for each of the 13 U.S. customers in the filtered list.

    graphics/08fig55.jpg

  15. Close Letters1 and save it with a descriptive name, such as USCustomersLetters.doc, and do the same for Document1, the main merge document (USCustomersMerge.doc).

graphics/power_tools.gif

The two documents created in the preceding steps are located in the \Seua10\Chaptr08\MailMerge folder of the accompanying CD-ROM. The merge document doesn't save the filter, so you must reestablish the filter when opening the main merge document.

Using an Existing Main Merge Document with a New Data Source

After you create a standard main merge document, the most common practice is to use different data sources to create form letters by addressee category. Word main merge documents store database and table connection data, and retain filter settings. Using Access filters or queries to restrict the recipient list usually is more convenient than performing the same operation in Word.

Take the following steps to use the main mail-merge document you created in the preceding section, USCustomersMerge.doc, with a data source based on a filter for the Customers table:

  1. graphics/removes_filter.gif In Access, open the Customers table in Datasheet view, and click the toolbar's Filter by Form button.

  2. Scroll to the Country field, open the field list and select USA.

  3. graphics/apply_filter.gif Click the Apply Filter button to filter the table data and display only U.S. customers.

  4. graphics/advanced_filter.gif Choose Records, Filter, Advanced Filter/Sort to open the Filter Design window, which displays the filter criterion you applied in step 2. Drag the PostalCode field to the second column, and select an Ascending sort (see Figure 8.56).

    Figure 8.56. The Filter Design window opened by the Advanced Filter Sort command displays the filter for the Customers table with an ascending sort on the PostalCode field.

    graphics/08fig56.jpg

    To review use of Access's Advanced Filter/Sort feature, see "Applying Advanced Filters and Sort Orders," p. 255.


  5. Choose File, Save As Query, give your filter a descriptive name, such as fltUSCustomers, and click OK.

  6. graphics/a_single_queries.gif Close the Filter window and the Customers table, and click the Queries shortcut of the database window.

  7. Double-click the filter item, fltUSCustomers for this example, to open the query result set and test the filter. Close the Query Datasheet window.

  8. graphics/fom_letters.gif Click the Merge It with Microsoft Word button to launch the Mail Merge Wizard. With the Link Your Data to an Existing Microsoft Word Document option marked (the default), click OK to open the Select Microsoft Word Document dialog.

  9. Navigate to and double-click your main merge document, USCustomersMerge.doc for this example, in the file list. After a few seconds, Word opens, and Access's title bar flashes. Minimize Word to expose the message box, shown in Figure 8.57. Click Yes to change to the new data source.

    Figure 8.57. When you change the data source for a main merge document, Word opens a message box.

    graphics/08fig57.gif

  10. If Word can't resolve the data source type, the Confirm Data Source dialog opens to verify use of an OLE DB data source for the Jet query. Accept the default OLE DB Database Files, and click OK to continue in Word.

    Tip

    If you attempt to connect to an open document, you receive a "File in Use" error message. Click Cancel, and then click OK when the "Command Failed" error message appears. Close the merge document, and try again.

  11. graphics/mail_merge.gif Restore Word and confirm that the filter is the new merge data source [fltUSCustomers] in "Northwind.mdb" in the task pane's Mail Merge page (see Figure 8.58). Double-check the list by clicking the Mail Merge Recipients button. Only the filtered records appear in the list. Click OK to close the list.

    Figure 8.58. The Mail Merge task pane page confirms the document is using the fltUSCustomers filter.

    graphics/08fig58.jpg

  12. graphics/merge_new_document.gif graphics/mail_merge_print.gif graphics/mail_merge.gif You can merge the main document and data source directly to the printer, spam the customers via email, send faxes, or create a series of form letters in a new document, which is identical to the sample document you created in the preceding section.

If you close Word at this point, be sure to save your changes to the main mail-merge document.



Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net