Microsoft Knowledge Base Email Alertz

KBAlertz.com: 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

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 2.0 Web Hosting with SQL 2005: Click Here!
Discount ASP.NET Hosting


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




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
Last Review:February 10, 2007
Revision:2.0

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.

Back to the top

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.

Back to the top

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 (http://msdn2.microsoft.com/en-us/library/aa163992(office.10).aspx)

Back to the top

Steps to reproduce the problem

1.Open Access.
2.On the File menu, click New.
3.Click Blank database, type db1.mdb in the File name box, and then click Create.
4.Click Tables, right-click Create table in Design view, and then click Open.
5.In the first Field Name box, type F1, and then click Text in the first Data Type list.
6.In the second Field Name box, type F2, and then click Text in the second Data Type list.
7.On the File menu, click Save.
8.In the Table Name box, type Table1, and then click OK.
9.In the dialog box that appears, click No, and then close Design view for the table that you created.
10.Click Modules, and then click New.
11.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("Table1").CreateField("AAA", 4) '"AAA" create field
        db.TableDefs("Table1").Fields.Append fld '"AAA" add field
        db.TableDefs("Table1").Fields("AAA").OrdinalPosition = 0 '"AAA" move field location
        db.Close 'Database object Close
        test = "END" 'execution is completed
End Function
12.On the Tools menu, click References, select the Microsoft DAO 3.6 Object Library check box, and then click OK.
13.On the Run menu, click Run Sub/UserForm.
14.On the File menu, click Close and Return to Microsoft Office Access.
15.Click Tables, right-click Table1, and then click Open.
Notice that the new column is not set as the first column in the table.

Back to the top

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Back to the top


APPLIES TO
Microsoft Office Access 2003
Microsoft Access 2002 Standard Edition
Microsoft Access 2000 Standard Edition

Back to the top

Keywords: 
kbprb kbinfo kbbug kbexpertiseadvanced kbexpertiseinter kbtshoot kbsample KB927417

Back to the top

       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please