Change colour in reports?

G

Guest

Is it possible to dynamically change the back colour of a report text box
through code? For example, my report groups the recordset by a "colour"
field (values of Red, Green, Yellow). Is there a way to change the back
colour of this field based on it's value? Thanks.
 
M

Marshall Barton

REC said:
Is it possible to dynamically change the back colour of a report text box
through code? For example, my report groups the recordset by a "colour"
field (values of Red, Green, Yellow). Is there a way to change the back
colour of this field based on it's value?


Use the text box section's Format (or Print) event to run
code like:

Select Case Me.txtColor ' text box for colour field
Case "Red"
Me.txtColor.BackColor = RGB(255, 0, 0) 'Red
Case "Green"
Me.txtColor.BackColor = RGB(0, 255, 0) 'Green
Case "Yellow"
Me.txtColor.BackColor = RGB(255, 255, 0)
Case "Pink"
Me.txtColor.BackColor = RGB(255, 224, 224)
. . .
Case Else
Me.txtColor.BackColor = RGB(255, 255, 255) 'White
End Select
 
G

Guest

Many thanks!

Marshall Barton said:
Use the text box section's Format (or Print) event to run
code like:

Select Case Me.txtColor ' text box for colour field
Case "Red"
Me.txtColor.BackColor = RGB(255, 0, 0) 'Red
Case "Green"
Me.txtColor.BackColor = RGB(0, 255, 0) 'Green
Case "Yellow"
Me.txtColor.BackColor = RGB(255, 255, 0)
Case "Pink"
Me.txtColor.BackColor = RGB(255, 224, 224)
. . .
Case Else
Me.txtColor.BackColor = RGB(255, 255, 255) 'White
End Select
 

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