Table Fields.
You can use the ColumnWidth property to specify the width of a column in Datasheet view.
Note The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.
You can set this property by clicking the Column Width command on the Format menu in Datasheet view and entering the desired value.
In Visual Basic, the ColumnWidth property setting is an Integer value that represents the column width in twips. You can specify a width or use one of the following predefined settings.
Setting | Description |
0 | Hides the column. |
-1 | (Default) Sizes the column to the default width. |
-2 | Sizes the column to fit the visible text. |
Setting the ColumnWidth property to 0, or resizing the field to a zero width in Datasheet view, sets the fields ColumnHidden property to True and hides the field in Datasheet view.
Setting a fields ColumnHidden property to False restores the fields ColumnWidth property to the value it had before the field was hidden. For example, if the ColumnWidth property was -1 prior to the field being hidden by setting its ColumnWidth property to 0, changing the fields ColumnHidden property to False resets the ColumnWidth to -1.
The ColumnWidth property for a field isnt available when the fields ColumnHidden property is set to True.
ColumnHidden Property, ColumnOrder Property, RowHeight Property.
The following example changes the row height in Datasheet view of the Customers table to display two lines of data (450 twips) and sets the width of the Address column to 1.5 inches (2160 twips). These property settings will take effect the next time the Customers table is opened in Datasheet view.
To set the RowHeight and ColumnWidth properties, the example uses the SetTableProperty procedure, which is shown in the example for the DatasheetFontItalic and DatasheetFontUnderline properties, and the SetFieldProperty procedure, which is shown in the example for the ColumnHidden property.
Dim db As Database, tdCustomers As TableDefdb = CurrentDbtdCustomers = db![Customers]tdCustomers, "RowHeight", dbLong, 450tdCustomers![Address], "ColumnWidth", dbInteger, 2160
The next example takes effect in Datasheet view of the open Customers form. It sets the row height to 450 twips and sizes the column to fit the size of the visible text.
Forms![Customers].RowHeight = 450![Customers]![Address].ColumnWidth = -2