Chg font color based on checkbox value

R

Rob

I am trying to change the font color for a particular
record in a report based on the value of a check box for
that record. If the box is check (value = 1) then I want
the font for that entire record to be red. I've tried
the following with no luck:

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If Nz(Me!Check119, "") = "1" Then
Detail.BackColor - vbRed
Else
Detail.BackColor = vbWhite
End If

End Sub

I understand with this I am attempting to change the back
color of the entire detail area but I cannot see how to
access a text box's font color. Any help would be great!
Rob
 
F

fredg

Rob said:
I am trying to change the font color for a particular
record in a report based on the value of a check box for
that record. If the box is check (value = 1) then I want
the font for that entire record to be red. I've tried
the following with no luck:

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If Nz(Me!Check119, "") = "1" Then
Detail.BackColor - vbRed
Else
Detail.BackColor = vbWhite
End If

End Sub

I understand with this I am attempting to change the back
color of the entire detail area but I cannot see how to
access a text box's font color. Any help would be great!
Rob

Rob,

I sent the other post too soon....

A Check box's value can only be -1 or 0, never 1.
Alse, Detail.BackColor will change the backcolor of the entire Detail
section, not the backcolor of a control in the section.
Me![ControlName].BackColor will change the backcolor of the individual
control.
Me![ControlName].ForeColor will change the Font color.


If Me![Check119] = -1 Then
Me![ControlName].BackColor = vbRed
Me![ControlName].ForeColor = vbYellow
Else
Me![ControlName].BackColor = vbWhite
Me![ControlName].ForeColor = vbBlack
End If
 
F

fredg

fredg said:
Rob said:
I am trying to change the font color for a particular
record in a report based on the value of a check box for
that record. If the box is check (value = 1) then I want
the font for that entire record to be red. I've tried
the following with no luck:

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If Nz(Me!Check119, "") = "1" Then
Detail.BackColor - vbRed
Else
Detail.BackColor = vbWhite
End If

End Sub

I understand with this I am attempting to change the back
color of the entire detail area but I cannot see how to
access a text box's font color. Any help would be great!
Rob

Rob,

I sent the other post too soon....

A Check box's value can only be -1 or 0, never 1.
Alse, Detail.BackColor will change the backcolor of the entire Detail
section, not the backcolor of a control in the section.
Me![ControlName].BackColor will change the backcolor of the individual
control.
Me![ControlName].ForeColor will change the Font color.


If Me![Check119] = -1 Then
Me![ControlName].BackColor = vbRed
Me![ControlName].ForeColor = vbYellow
Else
Me![ControlName].BackColor = vbWhite
Me![ControlName].ForeColor = vbBlack
End If
Rob,
I just saw that I forgot to comment on your use of quotes around the
check box value, and the use of the Nz() function.

The check box value is a number datatype, not text, so no quotes.
Use = -1 not = "-1"
Also, there is no need for the Nz() function here as you only wish to
change the control color if the value is -1.
 
G

Guest

-----Original Message-----
Rob said:
I am trying to change the font color for a particular
record in a report based on the value of a check box for
that record. If the box is check (value = 1) then I want
the font for that entire record to be red. I've tried
the following with no luck:

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If Nz(Me!Check119, "") = "1" Then
Detail.BackColor - vbRed
Else
Detail.BackColor = vbWhite
End If

End Sub

I understand with this I am attempting to change the back
color of the entire detail area but I cannot see how to
access a text box's font color. Any help would be great!
Rob

Rob,

I sent the other post too soon....

A Check box's value can only be -1 or 0, never 1.
Alse, Detail.BackColor will change the backcolor of the entire Detail
section, not the backcolor of a control in the section.
Me![ControlName].BackColor will change the backcolor of the individual
control.
Me![ControlName].ForeColor will change the Font color.


If Me![Check119] = -1 Then
Me![ControlName].BackColor = vbRed
Me![ControlName].ForeColor = vbYellow
Else
Me![ControlName].BackColor = vbWhite
Me![ControlName].ForeColor = vbBlack
End If


--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
That worked perfect. Thank you very much!
Rob
 

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