Changing font color if value for another field equals...

VegaLA

Registered User.
Local time
Today, 09:40
Joined
Jul 12, 2006
Messages
101
Hi all,
I'm having a problem getting a txtbox to display
the font color blue if the value of another specific txtbox is equal to "Computer", if the value is anything else the text color should remain black. However when the form is open all the Asset fields font color is blue. The code I have ( placed in the forms on open event) is below:

Private Sub Form_Open(Cancel As Integer)

If Me.Type = "Computer" Then
Me.Asset.ForeColor = vbBlue
Else: Me.Asset.ForeColor = vbBlack

End If

End Sub

I'm wondering if placing that code on the forms on open event is the wrong place to put it ?
If anyone can help me out that would be great.

Mitch.......
 
Presuming you're using Access 2000 or later, this is easier to achieve with Conditional Formatting.
 
Awp yeah, I have changed the control and the field name to HType.

OK, I have placed the code to the on Current event ( the form is a continous form view) but still no joy but I shall look into conditional formatting since I am using Access 2002.

Thanks,
Mitch.........
 
The Current event will not work for you with a Continuous form. Conditional formatting is the best option in your case as long as your control is a TextBox.
 
Thanks.
I just tried Conditional formatting and it still highlights all the records for that field in blue, and this is probably due to the fact I am using continous forms to display the records so I may have to re-think the display.

Thanks again though.
 
Conditional Formatting *will* work correctly on your Continuous Form if the "other" field is on the same record.
 
It may have to do with how you set it up (you did go into Format/Conditional Formatting?). Conditional Formatting is perfect for continuous forms and should do exactly what you described.
 

Users who are viewing this thread

Back
Top Bottom