Microsoft KB Archive/282367

= ACC2002: Table Names Displayed Incorrectly in a Microsoft Access Project =

Article ID: 282367

Article Last Modified on 1/26/2005

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282367



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

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
Table names in Microsoft Access project may be displayed incorrectly. They may be inside quotation marks or may appear broken, with their parts transposed and inside parenthesis. For example, the table name Categories may be displayed in ways similar to the following:

&quot;Cate)gories&quot;

-or-

&quot;gories&quot;&quot;(&quot;Cate&quot;)



CAUSE
This behavior occurs when a table name contains characters that are not allowed in Microsoft Access project table names, such as a period (.), an exclamation point (!), an accent grave (`), brackets ([ ]) or a double quotation mark (&quot;).



RESOLUTION
If a table name in your Microsoft Access project contains one or more of the disallowed characters, you can still change it back to its original name or to any other valid name. To do so, use one of the following methods.

NOTE: If any of the existing queries, views, user-defined functions, stored procedures, or programs refer to the misnamed table, the name modification will make these objects invalid.

Method 1
This method requires that you have access to the Microsoft SQL Server where your database is located and the necessary permissions to delete and create tables in your database.
 * 1) Start the SQL Server Enterprise Manager.
 * 2) Expand the  , Databases,  , and then Tables.
 * 3) Locate the table in the table list in the right pane.
 * 4) Right-click the table, and then click Rename on the shortcut menu.
 * 5) Rename your table to a new name, and then press ENTER.
 * 6) Quit the SQL Server Enterprise Manager.

Method 2
This method allows you to change the table name directly from Microsoft Access. Initially, a system table is queried to establish the correct spelling of the table name as it exists on the server. A stored procedure is then used to rename the table. The example shown here is based on the &quot;Steps to Reproduce the Behavior&quot; section of this article.  Open your Microsoft Access project. In the Database window, click Queries under Objects. Double-click Create view in designer. Click Close, and then click SQL on the toolbar.  Type the following text in the SQL pane:   SELECT name FROM sysobjects WHERE xtype = 'U'                    On the Query menu, click Run. Before the query runs, you are prompted to save the view. Save the view as qryUserTables .</li> Examine the list of tables and locate the table with a period, a bracket, a quotation mark, an exclamation mark, or a grave accent in its name, for example, Cate&quot;.gories. This table would be incorrectly displayed in the Access Database window as &quot;gories&quot;&quot;(&quot;Cate&quot;)&quot;. Note the exact spelling.</li> Press ALT+F11 to open the Visual Basic Editor.</li> Press CTRL+G to open the Immediate window.</li>  Enter the following command: CurrentProject.Connection.Execute &quot;sp_rename '[Cate&quot;&quot;.gories]', 'Categories'&quot; You must enter the double quotation mark (&quot;) in the table name twice (that is, &quot;&quot;), and you must include the whole table name in square brackets ([]). </li> Press ENTER to carry out the command.</li> Press ALT+F11 to switch to Access.</li> In the Database window, press F5 to refresh the view.

The table name has been changed.</li></ol>

<div class="moreinformation_section">

MORE INFORMATION
Microsoft Access does not allow object names containing periods and double quotations, and prevents such names from being created by means of the user interface. However, the SQL Server allows all of these characters in its table names and displays the names correctly. Object names may be changed by code or by a user in the SQL Server user interface. When such objects exist in SQL Server based databases, their names will not be displayed correctly in the Database window of your Access project.

Steps to Reproduce the Behavior
<ol> Start Microsoft Access and open the sample project NorthwindCS.adp connected to SQL Server 2000.</li> Press ALT+F11 to open the Visual Basic Editor.</li> Press CTRL+G to open the Immediate window.</li>  To change the name &quot;Categories&quot; to &quot;Cate&quot;.gories&quot;, type the following code in the Immediate window, and then press Enter: CurrentProject.Connection.Execute &quot;sp_rename 'Categories', 'Cate&quot;&quot;.gories'&quot; NOTE: You must use &quot;&quot; to designate a double quotation mark (&quot;). </li> Close the Visual Basic Editor to return to the Database window.</li> Press F5 to refresh the table list.</li></ol>

Notice that the table name listed in the Database window is:

&quot;gories&quot;&quot;(&quot;Cate&quot;)

<div class="references_section">