Change row or text box color in report

D

Darby Holmes

How can I either change a text box (in a Report) or the
font color when the value equals, for
instance, 'Rejected'.

Or better yet, how can I make the Report so the whole row
with the other text boxes changes to the color red when
the one textbox (in this case 'Status') equals 'Rejected??

Thanks,

Darby
 
F

fredg

How can I either change a text box (in a Report) or the
font color when the value equals, for
instance, 'Rejected'.

Or better yet, how can I make the Report so the whole row
with the other text boxes changes to the color red when
the one textbox (in this case 'Status') equals 'Rejected??

Thanks,

Darby
Darby,
Here a 3 choices for you.

1) How about just changing the color of the entire detail section for
that record?
In the Report's Detail Format event:

If [Status] = "Rejected" Then
Me.Section(0).BackColor = vbRed
Else
Me.Section(0).BackColor = vbWhite
End If
Set the backStyle of each control in the section to Transparent.

Or..

2) If you wanted just to change the forecolor only, you would need to
either mention each control by name.
In the Report's Detail Format event:

If [Status] = "Rejected" Then
Me![LastName].ForeColor = vbRed
' etc.
Else
Me![LastName].ForeColor = vbBlack
' etc.
End If


Or ...
3) If many controls forecolor need to be changed, cycle through the
controls collection. The below will change all text and label
controls. Add combo, check boxes, etc., if needed.

Dim c As Control
For Each c In Me.Section(0).Controls
If TypeOf c Is TextBox Or TypeOf c Is Label Then
' Reset each control to it's default Black
c.ForeColor = vbBlack
End If
If [Status] = "Rejected" Then
If TypeOf c Is TextBox Or TypeOf c Is Label Then
' Set each control to Red if [Status] meets the criteria.
c.ForeColor = vbRed
End If
End If
Next

Hope this helps.
 
D

Darby Holmes

Wow! Thanks
-----Original Message-----
How can I either change a text box (in a Report) or the
font color when the value equals, for
instance, 'Rejected'.

Or better yet, how can I make the Report so the whole row
with the other text boxes changes to the color red when
the one textbox (in this case 'Status') equals 'Rejected??

Thanks,

Darby
Darby,
Here a 3 choices for you.

1) How about just changing the color of the entire detail section for
that record?
In the Report's Detail Format event:

If [Status] = "Rejected" Then
Me.Section(0).BackColor = vbRed
Else
Me.Section(0).BackColor = vbWhite
End If
Set the backStyle of each control in the section to Transparent.

Or..

2) If you wanted just to change the forecolor only, you would need to
either mention each control by name.
In the Report's Detail Format event:

If [Status] = "Rejected" Then
Me![LastName].ForeColor = vbRed
' etc.
Else
Me![LastName].ForeColor = vbBlack
' etc.
End If


Or ...
3) If many controls forecolor need to be changed, cycle through the
controls collection. The below will change all text and label
controls. Add combo, check boxes, etc., if needed.

Dim c As Control
For Each c In Me.Section(0).Controls
If TypeOf c Is TextBox Or TypeOf c Is Label Then
' Reset each control to it's default Black
c.ForeColor = vbBlack
End If
If [Status] = "Rejected" Then
If TypeOf c Is TextBox Or TypeOf c Is Label Then
' Set each control to Red if [Status] meets the criteria.
c.ForeColor = vbRed
End If
End If
Next

Hope this helps.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal email
.
 

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