I have a userform that I would like to have the txtbox or combobox when active to have a red backcolor so the user knows where they are. How can I do that without having to add code to all the txtboxes and cmbboxes?
I have a userform that I would like to have the txtbox or combobox when active to have a red backcolor so the user knows where they are. How can I do that without having to add code to all the txtboxes and cmbboxes?
If possible have it change red when entered and then white when after exiting.
It's harder than you might think unless I've missed something about assigning event sinks to the MSForms.Control object. There is a method shown by Colo here.
Regards,
Rory
Microsoft MVP - Excel
[vba]
Private Sub TextBox1_Enter()
Me.TextBox1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.BackColor = RGB(255, 255, 255)
End Sub
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
is the tricky bit. Googling in fact located a post by you (xld) elsewhere pointing out that the Enter and Exit events are inherited from the container and therefore not exposed to the event sink (at least I think that's what you said!).How can I do that without having to add code to all the txtboxes and cmbboxes?
Regards,
Rory
Microsoft MVP - Excel
Yeah, shame, but that is how it is.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
And there's not even a ChangeControl method of the userform to use instead.
Regards,
Rory
Microsoft MVP - Excel
Yeah well I will use Xld's method I will do it for all of them manually. It works great. How can I get a list of all the color codes for excel. Like for Lite blue?
[vba]
Dim i as long
For i = 1 To 56
cells(i,"A").value = i
Cells(i,"B").Interior.Colorindex = i
Next i
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber