Microsoft KB Archive/824179

= Incorrect ColumnOrder value when you delete a column from a table that is opened in datasheet view =

Article ID: 824179

Article Last Modified on 3/29/2007

-

APPLIES TO


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

-





This article applies to either a Microsoft Access database (.mdb) file or to a Microsoft Access database (.accdb) file.

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



SYMPTOMS
When you delete a column from a table that is opened in the Datasheet view in Microsoft Access, the ColumnOrder property of the ActiveDatasheet property may display an incorrect value.



RESOLUTION
To resolve this problem, create or delete the column by using the Design view of the table.



WORKAROUND
To work around this problem, follow these steps:
 * 1) Start Access.
 * 2) Open the database that contains the table where the ColumnOrder property of the ActiveDatasheet property displays an incorrect value.
 * 3) In the Database window, select the table that displays the incorrect value, and then press CTRL+C.
 * 4) Press CTRL+V.
 * 5) In the Paste Table As dialog box, type Table2 in the Table Name box.
 * 6) Click to select Structure and Data, and then click OK.
 * 7) Rename the original table.
 * 8) Rename the Table2 table to the original table name.



MORE INFORMATION
Steps to Reproduce the Behavior  Start Access 2003 or an earlier version of Access. Create a new database.  Create a new table that is named Table1 with the following field properties: Field Name     Data Type Field1         Text Field2         Text Field3         Text Field4         Text Field5         Text Field6         Text Field7         Text  In the Database window, on the Insert menu, click Module.  In the Microsoft Visual Basic editor, paste or type the following code: Sub PrintColumnOrder Dim FRM As Form Dim CTL As Control Set FRM = Screen.ActiveDatasheet For Each CTL In FRM.Controls Debug.Print CTL.ColumnOrder Next CTL Set CTL = Nothing Set FRM = Nothing End Sub </li> Save the module as Module1.</li> Create a new form. Add a command button to the form.</li>  To print the ColumnOrder property of the table, add the following code to the OnClick event of the command button: DoCmd.OpenTable &quot;Table1&quot;, acViewNormal PrintColumnOrder DoCmd.Close acTable, &quot;Table1&quot;, acSaveNo </li> Save the form as Form1, and then close the form.</li> Open Table1 in Datasheet view.</li> Click Field4, and then insert a column. This will add the Field8 column to the right of Field4.</li> Reposition the Field4 column to the left of the Field8 column, save the changes, and then close the table.</li> Open the table in the Datasheet view.</li> To delete the Field4 column, select Field4, and then click Delete Column on the Edit menu.</li> Close the table.</li> Open the Form1 form, click the command button, and then press CTRL+G to view the results in the immediate window. Notice that the column order is printed as 1, 2, 3, 5, 5, 6, 7. This is incorrect.</li></ol>

<div class="references_section">

For more information about the ColumnOrder property, click Microsoft Visual Basic Help on the Help menu, type ColumnOrder in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: ACC2007

Keywords: kbdisplay kbpending kbview kbtable kbdataview kbprb KB824179

-

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

© Microsoft Corporation. All rights reserved.