Table of contents

Section.BackColor 属性 (访问)Section.BackColor Property (Access)

office 365 dev account|上次更新日期: 2018/3/13
2 参与人员

获取或设置指定对象的内部颜色。可读写的 LongGets or sets the interior color of the specified object. Read/write Long.


表达式背景色expression. BackColor

表达式_表示部分对象的变量。_expression A variable that represents a Section 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 属性(若有)设置为"Normal"。To use the BackColor property, the BackStyle property, if available, must be set to Normal.


下面的示例使用 RGB 函数来设置 BackColorForeColor 属性,具体视 txtPastDue 文本框的值而定。你也可以使用 QBColor 函数来设置这些属性。将下列代码添加到 Form_Current( ) 事件中,可以设置当用户打开窗体或移到新记录时的控件显示特性。The following example uses the RGB function to set the , BackColor, and ForeColor properties depending on the value of the txtPastDue text box. You can also use the QBColor function to set these properties. 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

另请参阅See also


部分对象Section Object

© 2018 Microsoft