I have a listbox with 2 columns: an error message, and the form control with the error. The 2nd column is hidden from the user. What I'm trying to do is when the user clicks on a row in the textbox it will setfocus for the control with the error. That part I got to work but even in my simple testing I noticed it was hard to see that the focus had changed to a different field so... what I'd like to do is change the background color for the error field and then when it looses focus set the background color back to the default. I can set the background color fine example:
strfield = Me.mylistbox.column(1)
Forms("Ticket").Controls(strfield).BackColor = dbYellow
But I'm having a hard time changing the lost focus event for the control at run time. If I do what I did for BackColor I get a "Object doesn't support this property or method"
example: Forms("Ticket").Controls(strfield).LostFocus = "somefunction"
I guess I could set the lostfocus event on every control to "somefunction" on the properties tab but that seems like overkill. Thoughts?
strfield = Me.mylistbox.column(1)
Forms("Ticket").Controls(strfield).BackColor = dbYellow
But I'm having a hard time changing the lost focus event for the control at run time. If I do what I did for BackColor I get a "Object doesn't support this property or method"
example: Forms("Ticket").Controls(strfield).LostFocus = "somefunction"
I guess I could set the lostfocus event on every control to "somefunction" on the properties tab but that seems like overkill. Thoughts?