Microsoft KB Archive/927417

= A table field appears incorrectly in Datasheet view when you add the field by using the Microsoft DAO Object Library and you set the OrdinalPosition property in Access =

Article ID: 927417

Article Last Modified on 2/10/2007

-

APPLIES TO


 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition
 * Microsoft Access 2000 Standard Edition

-



SYMPTOMS
After you add a field to a table in Microsoft Office Access, the field appears as the second column in the table. This problem occurs if the following conditions are true:
 * You add the field by using the Microsoft Data Access Objects (DAO) Object Library in Microsoft Office Access.
 * You change the value of the OrdinalPosition property of the field to display the field as the first column in the table.
 * You open the table in Datasheet view.



WORKAROUND
To work around this problem, follow these steps:
 * 1) In the Access database, click Tables, right-click the table that has the problem, and then click Open.
 * 2) On the File menu, click Save.
 * 3) Right-click the table that you saved in step 2, and then click Open.

Notice that the new column is now the first column in the table.



MORE INFORMATION
For more information about the Microsoft DAO 3.6 Object Library, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/aa163992(office.10).aspx



Steps to reproduce the problem
 Open Access. On the File menu, click New. Click Blank database, type db1.mdb in the File name box, and then click Create. Click Tables, right-click Create table in Design view, and then click Open. In the first Field Name box, type F1, and then click Text in the first Data Type list. In the second Field Name box, type F2, and then click Text in the second Data Type list.</li> On the File menu, click Save.</li> In the Table Name box, type Table1, and then click OK.</li> In the dialog box that appears, click No, and then close Design view for the table that you created.</li> Click Modules, and then click New.</li>  In the Module1 code window, paste the following code: Function test 'Object parameter decleration Dim db As DAO.Database Dim fld As DAO.Field

Set db = CurrentDb 'put current database into database object Set fld = db.TableDefs(&quot;Table1&quot;).CreateField(&quot;AAA&quot;, 4) '&quot;AAA&quot; create field db.TableDefs(&quot;Table1&quot;).Fields.Append fld '&quot;AAA&quot; add field db.TableDefs(&quot;Table1&quot;).Fields(&quot;AAA&quot;).OrdinalPosition = 0 '&quot;AAA&quot; move field location db.Close 'Database object Close test = &quot;END&quot; 'execution is completed End Function </li> On the Tools menu, click References, select the Microsoft DAO 3.6 Object Library check box, and then click OK.</li> On the Run menu, click Run Sub/UserForm.</li> On the File menu, click Close and Return to Microsoft Office Access.</li> Click Tables, right-click Table1, and then click Open.</li></ol>

Notice that the new column is not set as the first column in the table.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbprb kbinfo kbbug kbexpertiseadvanced kbexpertiseinter kbtshoot kbsample KB927417

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.