Set column width in a datasheet vith VBA

  • Thread starter Thread starter Lasse
  • Start date Start date
L

Lasse

Hi

Is it possible to set column width for each field in a datasheet with VBA
code?
Is it possible to hide/unhide columns to?

//Lasse
 
Hi Lasse

Each control on a form (or field in a table/query) has a ColumnWidth
property and a ColumnHidden property. ColumnWidth is expressed in "TWIPS"
(a twip is a twentieth of a point, so there are 1440 to the inch).

For example, the following code hides the column "EmployeeID" and sets the
width of "FirstName" to 2 inches:
EmployeeID.ColumnHidden = True
FirstName.ColumnWidth = 2880
 
Back
Top