Microsoft KB Archive/202859

= ACC2000: Aliased Field Name in Query Displays Wrong Name =

Article ID: 202859

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q202859



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

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



SYMPTOMS
When you build a query in the query by example (QBE) grid and use an alias for a column name, the name that you specified in the alias is not displayed when you run the query. Instead, an unexpected field name is returned in Datasheet view.



CAUSE
If a field in the underlying table of your query uses the Caption property, the value specified in the Caption property is displayed as the field name for a column, regardless of whether you use an alias. This behavior is by design.



MORE INFORMATION
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.

Steps to Reproduce Behavior:
 Open the sample database Northwind.mdb. In the Database window, click Tables under Objects, and open the Customers table in Design view. Select the ContactName field. Note that the Caption property for the ContactName field reads "Contact Name." Close the table. In the Database window, click Queries under Objects. Click New, and create a new query in Design view.</li> In the Show Tables dialog box, add the Customers table, and then click OK.</li> In the Field List box of the QBE grid, double-click the CustomerID field. Note that the field is added to the grid.</li> Add the following expression, which uses an alias, to the Field row of the second column in the query:

MyContactName: ContactName

</li> On the Query menu, click Run.

Note that the field name for the second column in the query is "Contact Name," not "MyContactName."</li></ol>

<div class="references_section">