Inconsistent CheckBox Color -- Anyone?

C

Cagey

Hi...sorry, over 30 days, so I've included the original thread below,
after End Select.
You wouldn't believe all I've tried, to get this to work consistently.
Issue it continues to have is if it turns the CheckBoxLabelName to the
correct color... as long as I keep the focus on that control it works
okay (turns on/off appropriately), but when I move from the control -
it keeps the color value of checked or unchecked, depending on the
record when the control had the focus. The control is in the Header
section of the form. Do you know how to resolve this so it works?

This is just a different attempt I made at the same thing.
Private Sub FakeName_LostFocus()
FontColor = 7602408
BackStyle = Normal
BackColor = 10092543
FontName = Arial

Select Case ChkBoxFINAL_Do_NOT_change

Case 1
CheckBox.Visible = -1 And Me.CurrentRecord = True
XYZName_Form.FINAL_Do_NOT_EDIT.Enabled
Format:
FINAL_Do_NOT_Edit_Label.BorderWidth = 1
FontWeight = Bold
FontSize = 10

Case 2
CheckBox.Visible = 0 And Me.CurrentRecord = True
XYZName_Form.FINAL_Do_NOT_EDIT.Enabled
FINAL_Do_NOT_Edit_Label.BorderWidth = Hairline
FontWeight = Medium
FontSize = 8
End Select


1 Cagey (Original post)
I set vb code so a checkbox on my form enables its label to change
color once it's checked. It works on GotFocus & has worked on Lost
Focus before (not currently), but mostly I want the label to stay that
color so it's always visible for only which ever record is check marked

this way, that means first thing when the db is opened, not only after
the field is activated. Anyone?

2 From: Michael H (Reply Date: Thurs, May 11 2006 3:21p)
Hi.
You didn't post your code, so I can't for certain tell you what to do
with
it. However, the following will work.
Make sure the Back Style property of the CheckBox's label is set to
Normal.
Place the following procedure in the code module of the Form (be sure
to
change CheckBoxName and CheckBoxLabelName to the actual names of your
controls):
Private Sub InitCheckBox()
If Me.CheckBoxName = -1 Then
Me.CheckBoxLabelName.BackColor = 255 'Red
Else
Me.CheckBoxLabelName.BackColor = -2147483633 'Original Grey
End If
End Sub
Then, in both the Form_Current event and the CheckBox's Click event,
place
the following line: InitCheckBox
If you do this, you can remove whatever code you had in the GetFocus
and
LostFocus events, as it will no longer be necessary. The Form_Current
event
will set the appropriate color when the form opens and every time you
move to
a new record, and the Click event will do the same each time the value
of the
CheckBox control changes.
-Michael

3 Cagey (Reply):
Thanks so much! Sounds great (like it should work)... tried it; didn't

work forgot to specify it's the color of the label text... so I
switched it to fore color instead of backcolor. Not sure what the -1
indicates? Will try again Monday; let me know if there's anything
different because it's the font color of the label instead -Thanks!!.
I'm out now until then. Have a great wknd!

4
From: Michael H (Reply Date: Fri, May 12 2006 10:08am)
Hi.
The value of a CheckBox is -1 when it is checked, and 0 when it is
unchecked, so the If statement is testing whether the CheckBox is
checked.
As for replacing "BackColor" with "ForeColor", there's nothing
different
except for the fact that you will probably want to change -2147483633
(Grey)
to 0 (Black). Otherwise, the label text will be the same color as the
form,
and therefore invisible. Also, it will then not be necessary to set
the Back
Style property of the CheckBox's label to Normal.
-Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top