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

取得或設定指定物件的內景色彩。Gets or sets the interior color of the specified object. 可讀寫的 LongRead/write Long.



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


BackColor 屬性包含數值運算式,代表用來填滿控制項或區段內部的色彩。The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

您可以在 Visual Basic 使用控制項的預設控制項樣式或**DefaultControl** 屬性來設定此屬性的預設值。You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

若要使用 BackColor 屬性, BackStyle 屬性,如果有,必須設定為 [正常。To use the BackColor property, the BackStyle property, if available, must be set to Normal.


下列範例會根據 txtPastDue 文字方塊的值,使用 RGB 函數以設定 BorderColorBackColorForeColor 屬性。The following example uses the RGB function to set the BorderColor, BackColor, and ForeColor properties depending on the value of the txtPastDue text box. 您也可以使用 QBColor 函數來設定這些屬性。You can also use the QBColor function to set these properties. 下列程式碼放置Form_Current () 事件中設定控制項顯示特性一旦使用者開啟表單或移動至新的記錄。Putting the following code in the Form_Current( ) event sets the control display characteristics as soon as the user opens a form or moves to a new record.

Sub Form_Current() 
 Dim curAmntDue As Currency, lngBlack As Long 
 Dim lngRed As Long, lngYellow As Long, lngWhite As Long 
 If Not IsNull(Me!txtPastDue.Value) Then 
 curAmntDue = Me!txtPastDue.Value 
 Exit Sub 
 End If 
 lngRed = RGB(255, 0, 0) 
 lngBlack = RGB(0, 0, 0) 
 lngYellow = RGB(255, 255, 0) 
 lngWhite = RGB(255, 255, 255) 
 If curAmntDue > 100 Then 
 Me!txtPastDue.BorderColor = lngRed 
 Me!txtPastDue.ForeColor = lngRed 
 Me!txtPastDue.BackColor = lngYellow 
 Me!txtPastDue.BorderColor = lngBlack 
 Me!txtPastDue.ForeColor = lngBlack 
 Me!txtPastDue.BackColor = lngWhite 
 End If 
End Sub

支援和意見反應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.