DisplayWhen Property [Access 2003 VBA Language Reference]

You can use the DisplayWhen property to specify which of a form's sections or controls you want displayed on screen and in print. Read/write Byte.

expression.DisplayWhen

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

Remarks

The DisplayWhen property applies only to the following form sections: detail, form header, and form footer. It also applies to all controls (except page breaks ) on a form.

The DisplayWhen property uses the following settings.

Setting Visual Basic Description
Always 0 (Default) The object appears in Form view and when printed.
Print Only 1 The object is hidden in Form view but appears when printed.
Screen Only 2 The object appears in Form view but not when printed.

Note  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 many cases, certain controls are useful only in Form view. To prevent Microsoft Access from printing these controls, you can set their DisplayWhen property to Screen Only. For example, you might have a command button or instructions on a form that you don't want printed. Or you might have form header and form footer sections that you don't want displayed on screen but that you do want printed. In this case, you should set the DisplayWhen property to Print Only.

Tip

FormatRetreatVisiblePrint

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

See Also | Visible Property