Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 824179 - Last Review: March 29, 2007 - Revision: 2.1
Incorrect ColumnOrder value when you delete a column from a table that is opened in datasheet view
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.
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.
To resolve this problem, create or delete the column by
using the Design view of the table.
To work around this problem, follow these steps:
- Start Access.
- Open the database that contains the table where the ColumnOrder property of the ActiveDatasheet property displays an incorrect value.
- In the Database window, select the table that displays the
incorrect value, and then press
CTRL+C.
- Press
CTRL+V.
- In the Paste Table As dialog box, type
Table2 in the Table Name
box.
- Click to select Structure and Data, and
then click OK.
- Rename the original table.
- Rename the Table2 table to the original
table name.
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 - Save the module as Module1.
- Create a new form. Add a command button to the
form.
- 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 - Save the form as Form1, and then
close the form.
- Open Table1 in Datasheet view.
- Click Field4, and then insert a column.
This will add the Field8 column to the right of Field4.
- Reposition the Field4 column to the left of the Field8
column, save the changes, and then close the table.
- Open the table in the Datasheet view.
- To delete the Field4 column, select
Field4, and then click Delete Column on the
Edit menu.
- Close the table.
- 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.
APPLIES TO
- Microsoft Office Access 2007
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
| kbdisplay kbpending kbview kbtable kbdataview kbprb KB824179 |
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