(I think I asked this ages ago, can't find the result )
On a report, to get over the Conditional Formatting limit of 3, I am trying to format an unbound text (Text25).
Here's a little example of code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Negotiator
Case "AW"
Text25.ForeColor = vbRed
Case "DP"
Text25.ForeColor = vbBlue
End Select
End Sub
Which doesn't work.
Can anyone enlighten me to make this work?
On Format - Report
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
On Format - Report
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: On Format - Report
Is Text25 a control in the Detail section? If not, the result is unpredictable.
ForeColor is the text colour - is that what you want?
Are you sure that Negotiator is a text field? (If it's entered using a combo box, it might actually be a number field)
ForeColor is the text colour - is that what you want?
Are you sure that Negotiator is a text field? (If it's entered using a combo box, it might actually be a number field)
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: On Format - Report
Text25 is a control in the detail section of the report, the width is as wide as all the results but set behind the actual data. So when a condition is met, it should change colour and showing through the report results. The report results back colour are set to transparent.
Negotiator is a text field ie "AW" "DP" "DW" etc.
So was my example correct other than the "Forcolor" error ?
Negotiator is a text field ie "AW" "DP" "DW" etc.
So was my example correct other than the "Forcolor" error ?
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: On Format - Report
I'd omit the Text25 control, and set the BackColor property of the Detail section itself:
Me.Detail.BackColor = vbRed
etc.
Me.Detail.BackColor = vbRed
etc.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1728
- Joined: 25 Jan 2010, 08:34
- Location: Stoke on Trent - Staffordshire - England
Re: On Format - Report
Got it:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Negotiator
Case Trim("AW")
Me.Detail.BackColor = vbRed
Case Trim("DP")
Me.Detail.BackColor = vbBlue
End Select
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Negotiator
Case Trim("AW")
Me.Detail.BackColor = vbRed
Case Trim("DP")
Me.Detail.BackColor = vbBlue
End Select
End Sub
Cheers ...
Dave.
Dave.
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: On Format - Report
You don't need Trim in the Case parts. Trim("AW") is exactly the same as "AW", etc. If there's a chance that there's a space before or after the value of Negotiator, you could use
Select Case Trim(Negotiator)
Select Case Trim(Negotiator)
Best wishes,
Hans
Hans