Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change color of text depending on value entered 1

Status
Not open for further replies.

jaegca

Instructor
Dec 5, 2001
20
US
I have a main form with a subform - the subform has a field (Primary Key) that I used a combo box to display a text field so data entry is by a drop down text selection. My problem is that I want the field to display a different Forecolor depending on what is entered (Red - Green - Yellow). I tried an If / else if in the Form properties of the subform in the OnCurrent event and AfterUpdate events.
IF (Me!AuthStatusID)="Pending" Then
Me!AuthStatusID.ForeColor = 127976
ElseIf (Me!AuthStatusID)="Received" Then
Me!AuthStatusID.ForeColor = 4367885
Else Me!AuthStatusID.ForeColor = 32768
EndIf
Also tried the Autonumber for the field instead of the text
Also tried the same code both ways on the actual control
Also tried the same code both ways on the form properties of the Main Form

Any ideas anyone? Any feedback would be greatly appreciated. Thanks so much, Cindy
 
Take a look at conditional formatting. To set it up for a control go to design view, select the control, and go to Format -> Conditional Formatting. Here you can set up expressions dealing with any Field you want in the form to change the color.

This will work if you only want up to 4 colors, including the default color.

If you want more than that, it's beyond my knowledge, but a search on these forums for conditional formatting would probably be useful. I know there are ways to do just about whatever you need.

Hope some of that helps.
 
Loktar, I am using Access 97 - when I went to the control's properties, there is no option available for conditional formatting - am I looking in the wrong place or is it a version issue? Thanks much, cindy
 
Use a Select Case statement in the after update of the combo box:

Code:
Select Case Me.[i]cboYourBoxName[/i]
Case Is = "Pending"
    Me.[i]cboYourBoxName[/i].ForeColor = 127976
Case Is = "Received"
    Me.[i]cboYourBoxName[/i].ForeColor = 4367885
[i][b]continue for each color/scenerio[/b][/i]
End Select

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top