Results 1 to 2 of 2

Thread: Changing Colors

  1. #1

    Thread Starter
    Registered User
    Join Date
    May 1999
    Location
    Melbourne, Victoria, Australia
    Posts
    47

    Question

    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

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    Perth Western Australia
    Posts
    41

    Cool

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width