Change text box background color depending on value in Label Reports

  • Thread starter Thread starter harrissteinman
  • Start date Start date
H

harrissteinman

Hi, hope someone can help. Struggling with this.

I have designed in MsAccess 2007 a Reports to print Labels 3 across.

I would like a specific field to change background color according to the value of the field. Using Conditional formatting, I can enable this but only for three values. However I am using more than 3 values.

In other words, if the value of the text box is "Milk", the text box background should be yellow; if "Wheat", should be red; if "Egg", should be green; etc. Is this possible or have I been wasting my time!

Harris
 
Not sure if your still looking for an answer but you can simulate conditional formatting using VBA. In the Detail Sections On Format event you can add something like this to change the color:

Code:
Select Case Me.ctlText
Case "Milk"
Me.ctlText.BackColor = RGB(255, 0, 0)
Case "Egg"
Me.ctlText.BackColor = RGB(0, 255, 0)
Case "Wheat"
Me.ctlText.BackColor = RGB(0, 0, 255)
Case "Potato"
Me.ctlText.BackColor = RGB(125,125,125)
Case else
End Select

This code will only fire when you print or are in print preview.
 
Back
Top