Coloring individual cells

  • Thread starter Thread starter Darrin7
  • Start date Start date
D

Darrin7

Guest
Does anyone know if it's possible to manipulate individual record cells' color from say white to aqua given a criteria? My records contain chemical data with outputs like "3," "1U," "5.2UJ." The datatype is Text for these records. So far, I've created a transparent label (called Highlight) over an individual record text box in the Detail section of the report that turns aqua given a criteria "<> 1U." Of course, this works only for those records with "1U." My main headache is: How do I set a criteria to color the cell if my record does not contain both a "U" or "UJ" label? More importantly, is there a way to globally format all the records in the report instead of doing this cell by cell? Here's what code looks like:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

On Error GoTo HandleErr
If Me.BENZENE <> "1U" Then
Me.Highlight.Visible = True
Else
Me.Highlight.Visible = False
End If

ExitHere:
Exit Sub
 
Look at the Instr function. If it finds the requested text in a string it returns an integer of the location of the text in the string. I'm not quite sure I understood what you were wanting to test for. However, if you want only records which do NOT contain a "U" you could use:

If Instr(Me.BENZENE,"U")>0 Then
Action for records with "U"
Else
Action for records without "U"
End If

Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom