ComboBox.DisplayWhen 屬性 (Access)ComboBox.DisplayWhen property (Access)

您可以使用 DisplayWhen 屬性來指定您想要顯示畫面和在列印此表單的控制項。You can use the DisplayWhen property to specify which of a form's controls you want displayed on screen and in print. 可讀寫的 ByteRead/write Byte.



_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.


DisplayWhen 屬性只適用於下列表單區段: 詳細資料、 表單首和表單尾。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.

DisplayWhen 屬性使用下列設定值。The DisplayWhen property uses the following settings.

設定Setting Visual BasicVisual Basic 描述Description
始終Always 00 (預設值) 物件在表單檢視時顯示,也在列印時顯示。(Default) The object appears in Form view and when printed.
列印時Print Only 11 物件在表單檢視時隱藏,但列印時顯示。The object is hidden in Form view but appears when printed.
顯示時Screen Only 22 物件在表單檢視時顯示,但列印時不顯示。The object appears in Form view but not when printed.

對控制項而言,您可以 Visual Basic 中使用的預設控制項樣式或**DefaultControl** 屬性來設定此屬性的預設值。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. 若要防止 Microsoft Access 列印這些控制項,您可以僅] 畫面上設定其 DisplayWhen 屬性。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. 在此例中,您應該僅列印設定 DisplayWhen 屬性。In this case, you should set the DisplayWhen property to Print Only.

對於報表,使用的格式Retreat事件來指定事件程序或巨集以設定您不想列印的控制項的Visible屬性。For reports, use the Format and Retreat events to specify an event procedure or macro that sets the Visible property of controls that you don't want printed. 您也可以取消的 格式Print 事件來防止區段列印在報表區段的。You can also cancel the Format or Print event for a report section to prevent the section from being printed.

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.