Microsoft KB Archive/210427

= ACC2000: How to Use the ColumnWidth Property =

Article ID: 210427

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210427



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

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



SUMMARY
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.



MORE INFORMATION
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 Datasheet view when the table or query is first opened in Datasheet view. If the table 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

