Combo Box Control, Command Button Control, Label Control, List Box Control, Text Box Control, Toggle Button Control.
You can use the ForeColor property to specify the color for text in a control. You can use this property for controls on forms to make them easy to read or to convey a special meaning. For example, you can change the color of the text in the UnitsInStock control when its value falls below the reorder level.
You can use this property on reports to create special visual effects when you print with a color printer. When used on a report, this property specifies the printing and drawing color for the Print, Line, and Circle methods.
The ForeColor property contains a numeric expression that represents the value of the text color in the control.
For reports, you can set the ForeColor property only in a macro or an event procedure specified in a section’s OnPrint event property setting.
For controls, set this property using the Formatting toolbar or the Color Builder.
You can also set this property using the controls default control style.
BackColor Property, BackStyle Property, Circle Method, DrawMode Property, DrawStyle Property, DrawWidth Property, FillStyle Property, Line Method, Print Method, QBColor Function, RGB Function.
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