In my access database, there is a Yes/No field named "No Longer Viable", and appropriatley, there is a No_Longer_Viable checkbox in my form. Whenever the data is loaded, and the box is checked or whenever they check the box during data entry, I want to change the text color of all other textboxes to be blue.

VB Code:
  1. Private Sub Form_AfterUpdate()
  2. ChColor
  3. End Sub
  4.  
  5. Private Sub Form_DataChange(ByVal Reason As Long)
  6. ChColor
  7. End Sub
  8.  
  9. Private Sub Form_DataSetChange()
  10. ChColor
  11. End Sub
  12.  
  13. Private Sub Form_Load()
  14.  
  15. End Sub
  16.  
  17. Private Sub Form_ViewChange(ByVal Reason As Long)
  18. ChColor
  19. End Sub
  20.  
  21. Private Sub No_Longer_Viable_Click()
  22. ChColor
  23. End Sub
  24.  
  25. Sub ChColor()
  26. If Me.No_Longer_Viable.Value <> 0 Then
  27.     For Each x In Controls
  28.         x.ForeColor = vbBlue
  29.     Next x
  30. Else
  31.     For Each x In Controls
  32.         x.ForeColor = vbBlack
  33.     Next x
  34. End If
  35. End Sub

If you know how to only change the textboxes blue instead of the labels as well, i would prefer that. I tried doing If not IsNull(x.text) then... but I got an error saying I can't retreive the value of an object if it isn't in focus. Maybe I could set the focus to the item first and then check it. Hm.
Thank you for any help,

James