Conditional Formatting

G

Guest

I have two checkboxes in an continuous form and I want to change the color of
labels which are associated with these checkboxes. I read sth on internet and
figured out I cant use conditional formatting with checkbox so I try to find
out another solution and came up with this. I deleted labels and add two
texboxes and tried to use conditional formatting on that texboxes. I chosed
Expression Is and wrote [MycheckboxName]=True as my condition in order to
change the color of textbox if checkbox is checked. Everything is ok but when
the backcolor of the texbox changes, it also changes the text with 0 or -1
which is weird for me. Is there any way to do it without changing text ? The
text in the textbox is static.
 
G

Guest

Hi

This would change the lable [LableA1] if you checked the checkbox
[MycheckboxName] Font will be Red and Bold. Back colour would be Yellow.
You will need to change the colors to what you want.


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

End Sub
 
G

Guest

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-I-M said:
Hi

This would change the lable [LableA1] if you checked the checkbox
[MycheckboxName] Font will be Red and Bold. Back colour would be Yellow.
You will need to change the colors to what you want.


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

End Sub


--
Wayne
Manchester, England.



Appache said:
I have two checkboxes in an continuous form and I want to change the color of
labels which are associated with these checkboxes. I read sth on internet and
figured out I cant use conditional formatting with checkbox so I try to find
out another solution and came up with this. I deleted labels and add two
texboxes and tried to use conditional formatting on that texboxes. I chosed
Expression Is and wrote [MycheckboxName]=True as my condition in order to
change the color of textbox if checkbox is checked. Everything is ok but when
the backcolor of the texbox changes, it also changes the text with 0 or -1
which is weird for me. Is there any way to do it without changing text ? The
text in the textbox is static.
 
G

Guest

Hi

You can't. If your checkbox is bound to a field then it's doing what it's
meant to.

Say the question is "Wayne likes a cup of tea with his lunch"
If the answer = True
Then this answer will stay like this until you uncheck the box "for this
record only" and the lable formating (see my last post) will stay like this.
It may be the someone else has the answer "false" and so the lables will stay
in the format (color, bold/not bold, etc) that you have set for this responce
"from this record".

This only way to save the formating would be to have an unbound check box -
but what would be the point of that.

Hope this helps.

--
Wayne
Manchester, England.



Appache said:
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-I-M said:
Hi

This would change the lable [LableA1] if you checked the checkbox
[MycheckboxName] Font will be Red and Bold. Back colour would be Yellow.
You will need to change the colors to what you want.


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

End Sub


--
Wayne
Manchester, England.



Appache said:
I have two checkboxes in an continuous form and I want to change the color of
labels which are associated with these checkboxes. I read sth on internet and
figured out I cant use conditional formatting with checkbox so I try to find
out another solution and came up with this. I deleted labels and add two
texboxes and tried to use conditional formatting on that texboxes. I chosed
Expression Is and wrote [MycheckboxName]=True as my condition in order to
change the color of textbox if checkbox is checked. Everything is ok but when
the backcolor of the texbox changes, it also changes the text with 0 or -1
which is weird for me. Is there any way to do it without changing text ? The
text in the textbox is static.
 
G

Guest

Ooops

Sorry forget all that (last post) I have just re-read your question.

Yes you can.

Copy the formating (don't delet it from the AfterUpdate - simply copy it)
and paste it into the OnLoad action. This will mean that the formating is
loaded when you open the form and it will also be actioned when you make
changes to the CheckBox.


--
Wayne
Manchester, England.



Appache said:
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-I-M said:
Hi

This would change the lable [LableA1] if you checked the checkbox
[MycheckboxName] Font will be Red and Bold. Back colour would be Yellow.
You will need to change the colors to what you want.


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

End Sub


--
Wayne
Manchester, England.



Appache said:
I have two checkboxes in an continuous form and I want to change the color of
labels which are associated with these checkboxes. I read sth on internet and
figured out I cant use conditional formatting with checkbox so I try to find
out another solution and came up with this. I deleted labels and add two
texboxes and tried to use conditional formatting on that texboxes. I chosed
Expression Is and wrote [MycheckboxName]=True as my condition in order to
change the color of textbox if checkbox is checked. Everything is ok but when
the backcolor of the texbox changes, it also changes the text with 0 or -1
which is weird for me. Is there any way to do it without changing text ? The
text in the textbox is static.
 
G

Guest

Thank you very much..I tried it and it worked but I didnt add your code to
under Form's Load action.I paste that code under Form's current action. I
also didnt delete this code from afterupdate action.
--
Thanks


Wayne-I-M said:
Ooops

Sorry forget all that (last post) I have just re-read your question.

Yes you can.

Copy the formating (don't delet it from the AfterUpdate - simply copy it)
and paste it into the OnLoad action. This will mean that the formating is
loaded when you open the form and it will also be actioned when you make
changes to the CheckBox.


--
Wayne
Manchester, England.



Appache said:
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-I-M said:
Hi

This would change the lable [LableA1] if you checked the checkbox
[MycheckboxName] Font will be Red and Bold. Back colour would be Yellow.
You will need to change the colors to what you want.


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

End Sub


--
Wayne
Manchester, England.



:

I have two checkboxes in an continuous form and I want to change the color of
labels which are associated with these checkboxes. I read sth on internet and
figured out I cant use conditional formatting with checkbox so I try to find
out another solution and came up with this. I deleted labels and add two
texboxes and tried to use conditional formatting on that texboxes. I chosed
Expression Is and wrote [MycheckboxName]=True as my condition in order to
change the color of textbox if checkbox is checked. Everything is ok but when
the backcolor of the texbox changes, it also changes the text with 0 or -1
which is weird for me. Is there any way to do it without changing text ? The
text in the textbox is static.
 

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