Conditional Formatting Question

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi All,

I would like to colour a small part of an action report dependent on who the
action is on, but it looks as though I can only have three conditions and I
need more.

Any idea how I can work round this please?

Ta.
Bill.
 
If you are comfortable with VBA code, you can use the Format event of the
section containing your text box to set its BackColor.

The BackColor is a number representing Red/Green/Blue values. The best way
to do this would be to create a little table with one record for each type
of action, and the color to use for each one, e.g.:
ActionTypeID Text primary key
ActionBackColor Number long integer

Include this table in the query that feeds your report, and output the
ActionBackColor field. Then set the On Format property of the report's
*section* to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Set up the code like this:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngColor As Long
lngColor = Nz(Me.ActionBackColor, vbWhite)
With Me.Text0
If .BackColor <> lngColor Then
.BackColor = lngColor
End If
End With
End Sub
 
Back
Top