ACC2000: Aliased Field Name in Query Displays Wrong Name

ID: Q202859


The information in this article applies to:

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: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Steps to Reproduce Behavior:

  1. Open the sample database Northwind.mdb.


  2. In the Database window, click Tables under Objects, and open the Customers table in Design view.


  3. Select the ContactName field. Note that the Caption property for the ContactName field reads "Contact Name."


  4. Close the table.


  5. In the Database window, click Queries under Objects.


  6. Click New, and create a new query in Design view.


  7. In the Show Tables dialog box, add the Customers table, and then click OK.


  8. In the Field List box of the QBE grid, double-click the CustomerID field. Note that the field is added to the grid.


  9. Add the following expression, which uses an alias, to the Field row of the second column in the query:


  10. MyContactName: ContactName
  11. On the Query menu, click Run.

    Note that the field name for the second column in the query is "Contact Name," not "MyContactName."



REFERENCES

For more information about the Caption property, click Microsoft Access Help on the Help menu, type "caption property" in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Additional query words: OFF2000 prb


Keywords          : kbdta QryOthr 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 15, 1999