View Full Version : How to make this 'universal' on form or to have fields refer to this through macro?


russi
03-07-2001, 07:27 AM
I need to have the current field on forms change color when they get focus and revert to original color when lost focus.
I wrote this code for a particular field and it works great!
PROBLEM IS that I have hundreds 9!!) of fields and numerous forms.
How would I make this universal for all fields or at least be able to refer to a macro for this code in each field (so I save having to change the reference to field name each time? PLEASE be explicit so I don't 'get lost'. THANKS.

here is my code:

Private Sub CONTACT_TIME_GotFocus()
Me.ActiveControl.ForeColor = QBColor(15)
Me.ActiveControl.BackColor = QBColor(9)
End Sub

Private Sub CONTACT_TIME_LostFocus()
Me.ActiveControl.ForeColor = 16777215
Me.ActiveControl.BackColor = 8421376
End Sub

Atomic Shrimp
03-07-2001, 08:46 AM
I know you've posted this again to get some fresh answers russ; I think I've cracked it!!

I've posted the answer on the original topic for continuity:
http://www.access-programmers.co.uk/ubb/Forum1/HTML/002869.html

Mike