BackColor Property

Applies To

Bound Object Frame Control, Chart Control, Combo Box Control, Image Control, Label Control, List Box Control, Option Group Control, Rectangle Control, Text Box Control, Unbound Object Frame Control.

Description

You can use the BackColor property to specify the color for the interior of a control or section.

Setting

The BackColor property contains a numeric expression that corresponds to the color used to fill a control or section’s interior.

You can set the BackColor property using the Formatting toolbar, a control’s property sheet, a macro, or Visual Basic.

You can also use the Color Builder to set this property by clicking the Build button to the right of the property in the property sheet. Using the Color Builder enables you to define custom back colors for controls.

In Visual Basic, use a numeric expression to set this property. This property setting has a data type of Long.

For controls, you can set the default for this property using a control’s default control style.

Remarks

To use the BackColor property, the BackStyle property, if available, must be set to Normal.

See Also

BackStyle Property, BorderColor Property, DrawMode Property, DrawStyle Property, DrawWidth Property, FillColor Property, ForeColor Property, PSet Method, QBColor Function, RGB Function.

Example

The following example uses the RGB function to set the BorderColor, 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
    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 IfSub