Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Answer for Appache

Discussion in 'Information Technology' started by Wayne-I-M, Jul 28, 2006.

Tags:
  1. Wayne-I-M

    Wayne-I-M
    Expand Collapse
    Guest

    Here is the answer
    (to "change the colour of a Label in response to an action")

    Place these codes on your form (open it in design view and right click the
    CheckBox – not the lable)

    I have assumed that your labels are called [LableA1] and [LableA2] so you
    will need to change these on your code. Also change the colours to whatever
    you want.

    Place this on the AfterUpdate

    Private Sub MycheckboxName_AfterUpdate()
    On Error GoTo MycheckboxName_AfterUpdate_Err

    If Me.MycheckboxName = 1 = True Then
    Me.LabelA1.BackColor = vbYellow
    Me.LabelA1.ForeColor = vbRed
    Me.LableA1.FontBold = True
    Else
    Me.LabelA1.BackColor = vbBlack
    Me.LabelA1.ForeColor = vbGreen
    Me.LableA1.FontBold = False
    End If

    If Me.MycheckboxName = 1 = True Then
    Me.LabelA2.BackColor = vbYellow
    Me.LabelA2.ForeColor = vbRed
    Me.LableA2.FontBold = True
    Else
    Me.LabelA2.BackColor = vbBlack
    Me.LabelA2.ForeColor = vbGreen
    Me.LableA2.FontBold = False
    End If

    End Sub

    Place this on the OnActivate of the “form†- NOT the Label. (right click
    the grey area outside the designed section of your form)

    Private Sub Form_Activate()
    If Me.MycheckboxName = 1 = True Then
    Me.LabelA1.BackColor = vbYellow
    Me.LabelA1.ForeColor = vbRed
    Me.LableA1.FontBold = True
    Else
    Me.LabelA1.BackColor = vbBlack
    Me.LabelA1.ForeColor = vbGreen
    Me.LableA1.FontBold = False
    End If

    If Me.MycheckboxName = 1 = True Then
    Me.LabelA2.BackColor = vbYellow
    Me.LabelA2.ForeColor = vbRed
    Me.LableA2.FontBold = True
    Else
    Me.LabelA2.BackColor = vbBlack
    Me.LabelA2.ForeColor = vbGreen
    Me.LableA2.FontBold = False
    End If

    End Sub



    Hope this helps

    --
    Wayne
    Manchester, England.



    "Appache" wrote:

    > Thank you for your answer but I think it's not the solution because when I go to next record and come back all the labels show up black again. I want to save the color unless somebody unchecks the checkbox.
    > Thanks
    >



    --
    Wayne
    Manchester, England.
     
  2. Loading...


Share This Page