Search code examples
vbacolorsms-wordbackground-color

Enable Controls - Colour stripping issue


I currently have a couple of checkboxes performing the below code.

Private Sub CheckBox2_Click()
    Dim en As Boolean
    en = CheckBox2.Value
    EnableControls Array(CheckBox3, CheckBox4, CheckBox5, CheckBox6, CheckBox7, CheckBox9, CheckBox10, CheckBox11, TextBox1), en

End Sub

Private Sub EnableControls(cons, bEnable As Boolean)
    Dim con
    For Each con In cons
        With con
            .Enabled = bEnable
            .BackColor = IIf(bEnable, vbWhite, RGB(240, 240, 240))
        End With
    Next con
End Sub

So when Checkbox=False the other checkbox fields are greyed out and you are unable to check them. However, once they are ungreyed out their whole back colour goes from the default "form background grey" to a bold white - any ideas on how to just grey the boxes out and when they are 'un-greyed' they just go back to their default colour????


Solution

  • A little testing shows you can leave your code as-is and set your checkboxes' BackStyle to fmBackStyleTransparent in the form designer