Re: how to have a checkbox change color and text of a label control?
- From: "Repent" <Repent34@xxxxxxxxxxx>
- Date: Sat, 21 Feb 2009 23:17:07 -0800
So could you make the label control box change color instead of the font?
"Repent" <Repent34@xxxxxxxxxxx> wrote in message
news:OFygbuLlJHA.4912@xxxxxxxxxxxxxxxxxxxxxxx
Thanks Dale that got it working! Now to learn about this coding
thing.....
chris
"Dale Fye" <dale.fye@xxxxxxxxxx> wrote in message
news:%23M9mSuJlJHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
Sorry, I copied from my earlier post, and forgot to rename the control
to the one you gave me.
Change that line to:
me.lbl_CanPlay.ForeColor = iif(me.chk_CanPlay, vbGreen, vbRed)
It should not mater if the control is bound or not, you just have to use
the correct names of the controls.
Dale
"Repent" <Repent34@xxxxxxxxxxx> wrote in message
news:OgCbZ7GlJHA.2460@xxxxxxxxxxxxxxxxxxxxxxx
When I apply your code and instructions I get the following error box:
Compile Error:
Method or data member not found
when I click "ok" to that I can see in the VB editor that the line that
states "Private Sub Form_Current () is highlighted yellow
and down in the code the phrase ".tickrelease" is highlighted in blue
The checkbox I'm trying to do this on is bound to a control source in my
table so I created another check box not bound to anything as a test and
got the same results.
You instructions seem clear to me but something is still amis.
chris
"Dale Fye" <dale.fye@xxxxxxxxxx> wrote in message
news:%23fjOaLClJHA.6124@xxxxxxxxxxxxxxxxxxxxxxx
Chris,
1. Name the checkbox and the label with similar names. If you want to
use "CanPlay" then I would name them chk_CanPlay and lbl_CanPlay. This
makes it easy to identify which control you are refering to in your
code.
2. When you look in the Event tab of the check boxes property window,
it will show as On Click, but when you actually look at the code in the
VB editor, it will read "chk_CanPlay_Click". Assuming the names
mentioned above, the code for that event should read:
Private Sub chk_CanPlay_Click
me.lbl_CanPlay.Caption = iif(me.chk_CanPlay, "Can Play", "Is not
resolved")
me.lbl_CanPlay.ForeColor = iif(me.tickRelease, vbGreen, vbRed)
End Sub
3. If it were me, I don't think I would change the caption of the
checkbox. I will frequently change the caption of a command button
(Save/Close) or something like that, but a checkbox is either True of
False, and I would set the caption and leave it as "Can Play".
You could also have put this code in the checkboxes AfterUpdate event
(both fire and have the same value whenever the checkbox is clicked).
Don't forget to put the code in the forms OnCurrent event as well.
Dale
"Repent" <Repent34@xxxxxxxxxxx> wrote in message
news:ODvYsg%23kJHA.4520@xxxxxxxxxxxxxxxxxxxxxxx
I'm not seeing "the tickRelease_Click event". I do see an "On Click"
event when I have the checkbox selected in design mode. When I put it
in there, by selecting event procedure and the ... and plugging that
code between the "Private Sub CanPlay__Click()" and the "End Sub" I
get the error of: "Compile error: Method or data member not found"
When I click ok to that error message I see in the editor that
".tickRelease" is highlighted Blue. Is that because I'm not in the
.tickRelease event? I tried changing the verbage to "On Click" and the
"OnClick" and still received errors.
The name of my label connected to the yes/no checkbox is "CanPlay". I
changed from "Is Resolved" to "CsnPlay", just FYI.
What am I doing wrong?
thanks;
chris
"Dale Fye" <dale.fye@xxxxxxxxxx> wrote in message
news:E90DA049-6704-4CC6-90C2-2707C99E0068@xxxxxxxxxxxxxxxx
I prefer:
me.lblRelease.ForeColor = iif(me.tickRelease, vbGreen, vbRed)
me.lblRelease.Caption = iif(me.tickRelease, "Is Resolved", "Is not
resolved")
In addition to putting this in the tickRelease_Click event, you
should also
put it in the forms Current event. If you don't do this, and open
the
record, then the label color and caption will not necessarily reflect
the
value that is in the checkbox.
--
HTH
Dale
email address is invalid
Please reply to newsgroup only.
"Repent34" wrote:
I have a form with a yes/no checkbox and it's accompanying label
control.
I'd like the checkbox to start out empty, with the label being a red
color
and the text "Not Resolved" to display. then when the user is
filling in
the form, and clicks in the yes/no box to put in a checkmark, the
label will
then turn green and the text "Resolved" shows up in the label
control.
I found this code while googling but not sure where it should be
plugged
into. New to all this.
Private Sub tickrelease_AfterUpdate()
If Me.tickrelease = True Then
Me.lblrelease.ForeColor = vbGreen
Me.lblrelease.Caption = "Is Resolved"
Else
Me.lblrelease.ForeColor = vbRed
Me.lblrelease.Caption = "Is Not Resolved"
End If
End Sub
.
- Follow-Ups:
- References:
- how to have a checkbox change color and text of a label control?
- From: Repent34
- RE: how to have a checkbox change color and text of a label control?
- From: Dale Fye
- Re: how to have a checkbox change color and text of a label control?
- From: Repent
- Re: how to have a checkbox change color and text of a label control?
- From: Dale Fye
- Re: how to have a checkbox change color and text of a label control?
- From: Repent
- Re: how to have a checkbox change color and text of a label control?
- From: Dale Fye
- Re: how to have a checkbox change color and text of a label control?
- From: Repent
- how to have a checkbox change color and text of a label control?
- Prev by Date: Re: how to have a checkbox change color and text of a label control?
- Next by Date: proofing tools for office 2003
- Previous by thread: Re: how to have a checkbox change color and text of a label control?
- Next by thread: Re: how to have a checkbox change color and text of a label control?
- Index(es):