Microsoft KB Archive/252740

= ACC2000: Query on a Table That Is Named with SQL Reserved Words Causes Error =

Article ID: 252740

Article Last Modified on 3/10/2003

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q252740



Moderate: Requires basic macro, coding, and interoperability skills.

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



SYMPTOMS
If you create a query based on a table that has a name beginning with the following Jet SQL reserved words

ALL (for example, "All YourName")

DISTINCT (for example, "Distinct YourName")

DISTINCTROW (for example, "Distinctrow YourName")

TOP  (for example, "Top 5 YourName")

followed by a space before the rest of the table name, you may receive the following error message when you run the query:

The Microsoft Jet database engine does not recognize 'YourName.*' as a valid field name or expression.



CAUSE
This behavior occurs because "ALL," "DISTINCT," "DISTINCTROW," and "TOP n" are Microsoft Jet SQL reserved words. Access interprets the SQL statement incorrectly, and does not initially recognize the reserved word as part of the table's name.



RESOLUTION
To resolve this problem, obtain Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a).

To obtain SR-1/SR-1a, click the article number below to view the article in the Microsoft Knowledge Base:

245025 OFF2000: How to Obtain and Install Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a)

To temporarily work around this problem, use one of the following methods.

Method 1: Save the Query in SQL View
Save the query in SQL view before running it. To save the query in SQL view, follow these steps:
 * 1) On the View menu, click SQL View.
 * 2) On the File menu, click Save.

The SQL statement should appear similar to the following example

SELECT [All ].* FROM [All  ];

where  is the rest of the name of the table that is used in the query.

Method 2: Rename the Table
You can also rename the table and omit the reserved word, or combine it with the next part of the table name (for example, "AllYourName" or "All_YourName").



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Office 2000 SR-1/SR-1a.



Steps to Reproduce Behavior
 Open a new blank Access database. Create a new table and save it as All MyName. Create a new query in Design view. In the Show Table dialog box, click All MyName, click Add, and then click Close. In the query design grid, double-click the asterisk (*) in the All MyName field list.</li> Save the query as qryTest, and then run the query.

Note that you receive the following error message:

The Microsoft Jet database engine does not recognize 'MyName.*' as a valid field name or expression.

</li></ol>

<div class="references_section">