Microsoft KB Archive/207597

= ACC2000: AutoLookup Field Returns Unexpected Value in Word Mail Merge =

Article ID: 207597

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207597



Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
When a Microsoft Word Mail Merge document displays AutoLookup fields from a table, the fields do not return the AutoLookup values as expected.



CAUSE
Microsoft Word Mail Merge does not use the RowSource property of the table fields to retrieve the lookup values, and retrieves the data values of the fields instead.



RESOLUTION
You must create a new query that includes the fields referred to in the RowSource property of the AutoLookup fields. Use this query as the data source for your Word Mail Merge document.

To display the AutoLookup values in a Word Mail Merge document, follow these steps.

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

Prepare for the Mail Merge

 * 1) Start Microsoft Access and open the sample database Northwind.mdb.
 * 2) In the Database window, click Tables under Objects, click the Orders table, and then click Design.
 * 3) Select the CustomerID field and, on the Lookup tab under Field Properties, examine the RowSource value. Note that AutoLookup uses the CustomerName field from the Customer table for its lookup value. This reference is used in step 10.
 * 4) Select the EmployeeID field and, on the Lookup tab under Field Properties, examine the RowSource value. Note that AutoLookup concatenates the LastName and FirstName field values from the Employees table for its lookup value.

These references are used in step 11.
 * 1) In the Database window, click the Queries tab, and then click New.
 * 2) In the New Query dialog box, select Design View, and then click OK.
 * 3) In the Show Table dialog box, select Employees, and then click Add.
 * 4) Repeat step 7 for the Orders table and the Customers table, and then click Close.
 * 5) From the Orders table, add all the fields except the CustomerID and EmployeeID fields to the query design grid.
 * 6) Add the CompanyName field from the Customers table to the query design grid.
 * 7) Add the LastName and FirstName fields from the Employees table to the query design grid.
 * 8) Save the query as MergeOrders, and then close it.

Running the Mail Merge

 * 1) In the Database window, click Queries under Objects, and then select the MergeOrders query that you created in the "Prepare for the Mail Merge" section.
 * 2) On the Tools menu, point to OfficeLinks, and then click Merge It with MS Word.
 * 3) In the Microsoft Word Mail Merge Wizard dialog box, click to select the Create a new document and then link the data to it check box, and then click OK.

Note that Microsoft Word starts and that a new, blank document is created.
 * 1) On the Mail Merge toolbar in Word, click the Insert Merge Field button. Note the list featuring all the fields in the Orders table, the CompanyName field from the Company table, and the LastName and FirstName fields from the Employees table. Select CompanyName from the list, and then press ENTER.
 * 2) Click the Insert Merge Field button, select LastName from the list to add it to the document, and then press COMMA and then SPACEBAR to separate the LastName field from the FirstName field.
 * 3) Click the Insert Merge Field button, select FirstName from the list, and then press ENTER.
 * 4) On the Mail Merge toolbar, click the View Merged Data button.

Note that the data presented in the Mail Merge document is composed of the same AutoLookup field values that are displayed in the Orders table.



Steps to Reproduce the Behavior
The following example demonstrates what occurs when you include an AutoLookup field from a table in a Mail Merge document.
 * 1) Start Microsoft Access and open the sample database Northwind.mdb.
 * 2) In the Database window, click Tables under Objects, and then click Orders.
 * 3) On the Tools menu, point to OfficeLinks, and then click Merge It with MS Word.
 * 4) In the Microsoft Word Mail Merge Wizard dialog box, click to select the Create a new document and then link the data to it check box, and then click OK.

Note that Microsoft Word starts and that a new, blank document is created.
 * 1) On the Mail Merge toolbar in Word, click the Insert Merge Field button. Note that a list of all the fields in the Orders table is displayed. Select CustomerID from the list, and then press ENTER.
 * 2) Click the Insert Merge Field button, and then select EmployeeID from the list.
 * 3) On the Mail Merge toolbar, click the View Merged Data button.

Note that the data presented in the mail merge does not contain the AutoLookup field values, but, rather, the actual EmployeeID and CustomerID values.

