Click to See Complete Forum and Search --> : Changing Colors
Paul Dudley
Jul 17th, 2000, 07:56 PM
Can anybody help me with the code to change the color of a form when the string in a Combo box on that form is changed. if the string "Active Client" is shown on a combo box I want the form current event to change the color of the form. Apparently you need to detail the combo properties and then the changes you want to make?
Thanks for your interest.
Paul - Melbourne/Australia
CGTS
Jul 17th, 2000, 09:09 PM
A problem you will encounter here is that the ordinary Combo box doesn't have a MouseUp event. Perhaps you could use a datacombo which has more events including MouseUp. If you want to fire the form colour change when the combo loses focus then No problem....... use the following code.
-----------------------------------------------------------
Private Sub Combo1_LostFocus()
If Combo1.Text = "Active Member" Then
Me.BackColor = vbGreen
Else
Me.BackColor = vbButtonFace
End If
End Sub
-----------------------------------------------------------
There is another way that is a bit sneaky and that is to use the Forms Mouse Move Event. The fact that the dropdown combo usually covers some of the form, when you have made your selection, the mouse is over the form and the mouse move event fires. The drawback here is if the mouse happens to be over another control when the selection is made. NOTHING HAPPENS! until you move the mouse over the form again.
-----------------------------------------------------------
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Combo1.Text = "Active Member" Then
Me.BackColor = vbGreen
Else
Me.BackColor = vbButtonFace
End If
End Sub
-----------------------------------------------------------
Professionally I would use a DataCombo!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.