Share via


Width Property [Access 2003 VBA Language Reference]

You can use the Height and Width properties to size an object to specific dimensions. Read/write Integer.

expression.Width

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

The Width property applies only to forms and reports, not to form sections and report sections.

Enter a number for the desired width in the current unit of measurement. To use a unit of measurement different from the setting in the Regional Options dialog box in Windows Control Panel, specify the unit, such as cm or in (for example, 5 cm or 3 in). The setting for the Width property must be a value from 0 to 22 inches (55.87 cm).

You can set this property by using the object's property sheet , a macro , or Visual Basic .

For controls, you can set the default for this property by using the default control style or the DefaultControl property in Visual Basic.

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

For report controls, you can set the Width property when you print or preview a report only by using a macro or an event procedure specified in a section's OnFormatevent property setting.

You can't set this property for an object once the print process has started.

Microsoft Access automatically sets the Width property when you create or size a control or when you size a window in form Design View or report Design view.

The width of forms and reports is measured from the inside of their borders. The width of controls is measured from the center of their borders so controls with different border widths align correctly. The margins for forms and reports are set in the Page Setup dialog box, available by clicking Page Setup on the File menu.

Note  To set the left and top location of an object, use the Left and Top properties.

Example

The following code resizes a command button to a 1-inch by 1-inch square button (the default unit of measurement in Visual Basic is twips; 1440 twips equals one inch):

Me!cmdSizeButton.Height = 1440    ' 1440 twips = 1 inch.
Me!cmdSizeButton.Width = 1440

Applies to | BoundObjectFrame Object | CheckBox Object | ComboBox Object | CommandButton Object | CustomControl Object | Form Object | Image Object | Label Object | Line Object | ListBox Object | ObjectFrame Object | OptionButton Object | OptionGroup Object | Page Object | Rectangle Object | Report Object | SubForm Object | TabControl Collection | TextBox Object | ToggleButton Object

See Also | Height Property