More than 3 Conditional Formatting

Cumberlandbm

New member
Local time
Today, 04:04
Joined
Apr 26, 2010
Messages
7
I'm trying to make a report where a certain field will have 5 different backgrounds depending on the situation in the field. I've looked up coding constantly getting the same thing. When I put my coding in and run it, the field turns blank and no color changes have also been made. Here's my coding, any help would be great. Priority is my textbox

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Priority

Case Is = "H"
Me.Priority.ForeColor = vbWhite
Me.Priority.BackColor = vbRed
Case Is = "M"
Me.Priority.ForeColor = vbBlack
Me.Priority.BackColor = vbYellow
Case Is = "L"
Me.Priority.ForeColor = vbWhite
Me.Priority.BackColor = vbGreen
Case Is = "E"
Me.Priority.ForeColor = vbWhite
Me.Priority.BackColor = vbBlue
End Select
End Sub
 
Try changing from Case is = "H" etc to Case H or Case "H", I don't know that the "is =" part is necessary.
 
Even after the changes, I still get a blank in the Priority text box.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me.Priority

Case "H"
Priority.ForeColor = vbWhite
Priority.BackColor = vbRed
Case "M"
Me.Priority.ForeColor = vbBlack
Me.Priority.BackColor = vbYellow
Case "L"
Me.Priority.ForeColor = vbWhite
Me.Priority.BackColor = vbGreen

Case "E"
Me.Priority.ForeColor = vbWhite
Me.Priority.BackColor = vbBlue
End Select
End Sub
 
How is this being called?

I copied and pasted into a db and it worked.
 

Attachments

I need it on a report, not a form. I have the information in a table, running a query to find specific information, then wanting the conditional formatting done on my report. Forgot to state I'm using version 2003.
 
Which version of Access are you using and which service pack are you on?
 
Sorry, might be confusing what you're asking. I am using Microsoft Access 2003 (11.8166.8221) SP3. I have Windows XP Professional Version 2002 Service Pack 3.
 
Make sure none of your fields have formats set for the fields at table level.
 
I need it on a report, not a form. I have the information in a table, running a query to find specific information, then wanting the conditional formatting done on my report. Forgot to state I'm using version 2003.

Silly for me, sorry for that....:eek:

Edit: To redeem myself, I got a report to work too, just pasting in your code... So I don't know what is going on. But it looks like Bob is helping you, and he is very capable, so I am sure you will be able to reach a solution.
 

Attachments

Last edited:
Too bad you don't have Access 2010 :D There are now 32 conditions available for conditional formatting.
 
This is at work, so they are slow to upgrade. There are no formats on the field in the table other than limiting the field size to 1 character. When I use the conditional formatting tool, everything works just fine, minus the extra colors I need. When I clear the conditional formatting tool and try using VBA, the blanks come into the text box and nothing is in it.
 
Make sure the text boxes have their BACKSTYLE property set to NORMAL and not transparent.
 
AH, that fixed it. Thank you so much, for whatever reason when I made the report with a wizard in Justified Layout, it set all the text boxes to Transparent.
 
I think it does that in any of the layouts in the Wizard. Glad you got it working as you wish. :)
 

Users who are viewing this thread

Back
Top Bottom