Change text box background color depending on value in Label Reports



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!

Feb 20, 2010
Reaction score
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:

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.

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