You are currently offline, waiting for your internet to reconnect

ACC2000: How to Use the ColumnWidth Property

This article was previously published under Q210427
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

This article discusses the ColumnWidth property, which applies to fields or columns in Datasheet view. This property is documented in the Microsoft Access Help index.
The ColumnWidth property applies to fields or columns in Datasheet view. It is an integer that represents the column width in twips. You can specify a width, or you can use one of the following predefined settings:
   Setting   Description   -----------------------------------------------------------------    0        Hides the column   -1        Sizes the column to the default width (default setting)   -2        Sizes the column to fit the visible text				
You can also set this property by clicking the Column Width command on the Format menu while in Datasheet view.

If you set a field's ColumnWidth property to 0 to hide the field, that field's ColumnHidden property is set to -1. If you set the field's ColumnHidden property to 0 to show the field, the field's ColumnWidth property is restored to the setting it had before the field was hidden. If you hide the field by setting its ColumnWidth property to 0, the ColumnWidth property is set to -1, which is the default width. Note that the ColumnWidth property for a field is not available when the field's ColumnHidden property is set to -1.

Microsoft Access evaluates the properties for a table or query in Datasheetview when the table or query is first opened in Datasheet view. If thetable or query is open in Datasheet view when you use Visual Basic to change a field's ColumnWidth property, the changes do not take effect until you close and then reopen the table or query in Datasheet view.

The form can be open in any view, and changes to the ColumnWidth property take effect immediately.

The following expression demonstrates how to set the ColumnWidth property for the Customers form in Datasheet view. This setting changes the Address column's width to 1.5 inches (2160 twips):
Forms![Customers]![Address].ColumnWidth = 2160
For more information about the ColumnWidth property, click Microsoft Access Help on the Help menu, type columnwidth property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Article ID: 210427 - Last Review: 12/05/2015 11:31:18 - Revision: 1.3

Microsoft Access 2000 Standard Edition

  • kbnosurvey kbarchive kbhowto kbprogramming KB210427