BackColor Property [Access 2003 VBA Language Reference]

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


expression Required. An expression that returns one of the objects in the Applies To list.


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

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

You can also set this property by using Fill/Back Color on the Formatting (Form/Report) toolbar, a control's or section's property sheet , a macro , or Visual Basic .

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

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

For Table objects you can set this property using Fill/Back Color on the Formatting (Datasheet) toolbar, or in Visual Basic by using the DatasheetBackColor property.


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


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
        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

Applies to | BoundObjectFrame Object | ComboBox Object | FormatCondition Object | Image Object | Label Object | ListBox Object | ObjectFrame Object | OptionGroup Object | Rectangle Object | Section Object | TextBox Object

See Also | BackStyle Property | BorderColor Property | Color Builder | DatasheetCellsEffect Property | DatasheetFontItalic Property | DatasheetFontName Property | DatasheetFontWeight Property | DatasheetGridlinesBehavior Property | DatasheetGridlinesColor Property | DrawMode Property | DrawStyle Property | DrawWidth Property | FillColor Property | ForeColor Property | PSet Method