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



The information in this article applies to:

  • Microsoft Office Access 2003
  • Microsoft Access 2002
  • Microsoft Access 2000

This article applies only to a Microsoft Access database (.mdb).

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. On the Edit menu, click Copy.
  4. On the Edit menu, click Paste.
  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
  1. Start Access.
  2. Create a new database.
  3. 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
  4. In the Database window, on the Insert menu, click Module.
  5. 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
  6. Save the module as Module1.
  7. Create a new form. Add a command button to the form.
  8. To print the ColumnOrder property of the table, add the following code to the OnClick event of the command button:
    DoCmd.OpenTable "Table1", acViewNormal
        PrintColumnOrder
        DoCmd.Close acTable, "Table1", acSaveNo
  9. Save the form as Form1, and then close the form.
  10. Open Table1 in Datasheet view.
  11. Click Field4, and then insert a column. This will add the Field8 column to the right of Field4.
  12. Reposition the Field4 column to the left of the Field8 column, save the changes, and then close the table.
  13. Open the table in the Datasheet view.
  14. To delete the Field4 column, select Field4, and then click Delete Column on the Edit menu.
  15. Close the table.
  16. 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.
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.

Modification Type:MinorLast Reviewed:6/8/2004
Keywords:kbdisplay kbpending kbView kbtable kbDataview kbprb KB824179 kbAudDeveloper