Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

適用對象

BoundObjectFrame 物件

ObjectFrame 物件

ComboBox 物件

OptionGroup 物件

FormatCondition 物件

Rectangle 物件

Image 物件

Section 物件

Label 物件

TextBox 物件

ListBox 物件

您可以使用 BackColor 屬性來指定控制項或章節的內部色彩。 讀/寫長整數

expression.BackColor

運算式 必要。 傳回 [套用至] 清單中其中一個對象的表達式。

設定

BackColor 屬性包含對應至用來填滿控制項或區段內部之色彩的數值運算式。

您可以使用 [色彩建立器] 設定此屬性,方法是在屬性工作表中,按一下屬性方塊右側的 [建立] 按鈕。 [色彩建立器​​] 可讓您為控制項或區段定義自訂的背景色彩。

您也可以使用控制項或區段的屬性工作表、巨集或 Visual Basic for Applications (VBA) 程式碼,或是使用 [字型] (位於 [設計] 或 [格式] 索引標籤,取決於您使用的是 [設計] 或 [版面配置] 檢視) 底下的 [填滿色彩] 命令,來設定此屬性。

在 Visual Basic for Applications (VBA) 程式碼中,使用數值運算式來設定此屬性。 此屬性設定包含 Long 資料類型。

您可以使用控制項的預設控制項樣式或 VBA 程式碼中的 DefaultControl 屬性,來設定此屬性的預設值。

針對 Table 物件,您可以使用 [資料] 索引標籤上 [字型] 底下的 [填滿色彩] 命令,或使用 DatasheetBackColor 屬性來設定此屬性。

備註

若要使用 BackColor 屬性,您必須將 BackStyle 屬性 (如果可用的話) 設為 Normal

範例

以下範例使用 RGB 函數設定 BorderColorBackColorForeColor 屬性 (視 txtPastDue 文字方塊的值而定)。 您也可以使用 QBColor 函數來設定這些屬性。 將以下程式碼加入 Form_Current( ) 事件會在使用者開啟表單或移至新記錄時設定控制項顯示特質。

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
Else
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
Else
Me!txtPastDue.BorderColor = lngBlack
Me!txtPastDue.ForeColor = lngBlack
Me!txtPastDue.BackColor = lngWhite
End If
End Sub

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×