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:
- In the Access database, click Tables, right-click the table that has the problem, and then click Open.
- On the File menu, click Save.
- 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:
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.
- On the File menu, click Save.
- In the Table Name box, type Table1, and then click OK.
- In the dialog box that appears, click No, and then close Design view for the table that you created.
- Click Modules, and then click New.
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
- On the Tools menu, click References, select the Microsoft DAO 3.6 Object Library check box, and then click OK.
- On the Run menu, click Run Sub/UserForm.
- On the File menu, click Close and Return to Microsoft Office Access.
- Click Tables, right-click Table1, and then click Open.
Notice that the new column is not set as the first column in the table.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Keywords: kbprb kbinfo kbbug kbexpertiseadvanced kbexpertiseinter kbtshoot kbsample KB927417