ACC: Word for Windows Print Merge Using Microsoft Access Data

ID: Q103629


The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0
  • Microsoft Word for Windows, versions 1.1, 1.1a, 2.0, 2.0a, 2.0b, 2.0c


SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

There is no Microsoft Word for Windows file converter capable of reading Microsoft Access database files. In order to use data from a Microsoft Access database in a Microsoft Word for Windows print merge, the data must first be exported from Microsoft Access in a format that Microsoft Word for Windows recognizes.

In Microsoft Access version 1.0, you can export the data in dBASE IV format. In Microsoft Access versions 1.1 and 2.0, you can export the data in Word For Windows Merge format. We do not recommend that you export Microsoft Access data to Word for Windows using the Text (Delimited format.


MORE INFORMATION

Exporting Data from Microsoft Access for Use in a Print Merge


  1. Open the Microsoft Access database table that contains the data you want to use in a Microsoft Word for Windows print merge.


  2. From the File menu, choose Export. In Microsoft Access version 1.1 or 2.0, select Word For Windows Merge in the Data Destination box. In Microsoft Access version 1.0 select dBASE IV as the data destination. Choose OK.


  3. From the Table list, select the table to be exported, and choose OK.

    NOTE: Microsoft Access only shows you a list of available tables to export. If you want to export a subset of a table, you can create a query to result in the subset you want, and export the results to a print merge data file. For information on how to export the results of a query to a file, query on the following words here in the Microsoft Knowledge Base:
    access and export and query and transfer and results


  4. Enter a unique filename in the File Name box. Select the appropriate destination directory in the Directory box and then choose OK.


Notes


  • Microsoft Access 1.1 will default the export filename to the same name as your table, with a .TXT extension, and will place the file in the Microsoft Access directory. Microsoft Access 1.0 will default the export filename to the same name as your table, with a .DBF extension. In either case, you may want to change the directory to your Microsoft Word for Windows directory and give the file a .DOC extension to make it easier to find in Word for Windows.


  • In Microsoft Access versions 1.1 and 2.0, you can select custom formats in the Export Options dialog box. These options determine how dates, times, and numbers are formatted in the data file. Although you can select custom formats, you do not need to make any changes in this dialog box.


  • In Microsoft Access 2.0, you can export the data with the Output To command from the File menu. You can output the table to Rich Text format, which Word for Windows can read.

    This format will maintain the table structure, if the table does not exceed Microsoft Word for Windows internal limits. This method does not correct the field names, which can cause problems with a Microsoft Word for Windows print merge. Problems with Microsoft Access field names in a Word for Windows print merge are discussed later in this article.


Using the Exported Data in Microsoft Word for Windows


  1. Open or create the main document in Microsoft Word for Windows.


  2. From the File menu, choose Print Merge.


  3. Choose Attach Data File.


  4. From the file list, select the exported file, and then choose OK.

    NOTE: You may have to type "*.TXT" or "*.DBF" (without the quotation marks) in the File Name box to see text or dBASE files in the filename list.


  5. Use the Insert Merge Fields tool on the print merge toolbar to insert fields in your main document. Consult the Microsoft Word for Windows documentation for information on how to use the merge features.


Problems Exporting Data Using the Text (Delimited) Format

One method of exporting data to Microsoft Word for Windows is to use the Text (Delimited) format. However, exporting the data in this format may require some changes to the exported data file before it can be used for a print merge.

The problem is that a number of restrictions are placed on field names used in a Microsoft Word for Windows print merge, including the following:
  • Field names cannot contain spaces.


  • Field names cannot begin with a number.


  • Field names cannot be longer than 20 characters in length.


  • Field names cannot contain special characters.


Microsoft Access field names do not have these restrictions. Consequently, you can export data from Microsoft Access that contains field names incompatible with Microsoft Word for Windows. If you use the Text (Delimited) format for exporting data, you may have to change the field names in the exported data file so that they meet the restrictions listed above.

If you use the dBASE IV or Word For Windows Merge formats, Microsoft Access will perform field name conversions to ensure that the data files will work correctly with Microsoft Word for Windows.

Microsoft Access Field Name Conversion

As discussed previously, Microsoft Word for Windows places a number of restrictions on the field names used in a print merge. Since Microsoft Access is not limited by these restrictions, it must perform field name conversions when exporting data to a print merge data file.

Microsoft Access performs field name conversions using the following rules:
  • Any spaces or illegal characters are converted to underscores.


  • If the first character in a field name is a number or an underscore, Microsoft Access adds the prefix "m_". For example, 1Field becomes m_1Field, and _Field2 becomes m__Field2.


  • Microsoft Access truncates field names that are longer than 20 characters.


  • If a conversion results in a duplicate field name, Microsoft Access adds a number to the end of each duplicate name (replacing the final character, if the field name contains twenty characters). For example, the field names Order#, Order$, and Order% become Order_, Order_1, and Order_2.


Keywords : kbinterop
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: March 25, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.