Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Format - More than 3? 2

Status
Not open for further replies.

bowieknife

Technical User
Oct 21, 2005
24
US
Is there an easy way to create more than 3 conditions using conditional formatting on an Access report?

If not, is there a good work-around?

Thanks.
 
bowieknife
Depending upon what you want to do with more than 3 conditions, I think you would have to use VBA code.

It would be helpful to explain what the conditions are.

Tom
 
If [Veh Code] = 32, 33, 82, 83, 94, or 95 Then [Veh Code] and [Veh Type] and [Sched Date] = vbgreen

If [Veh Code] = 14 or 67 Then [Veh Code] and [Veh Type] and [Sched Date] = vbred

If [Veh Code] = 01 Then [Veh Code] and [Veh Type] and [Sched Date] = vbblue
 
bowieknife
Try this...

On the OnFormat event for the Detail section of the report, put the following code:
Code:
If [Veh Code] = 32, 33, 82, 83, 94, or 95
Then [Veh Code] and [Veh Type] and [Sched Date] = vbgreen
Else
If [Veh Code] = 14 or 67
Then [Veh Code] and [Veh Type] and [Sched Date] = vbred
Else
If [Veh Code] = 01
Then [Veh Code] and [Veh Type] and [Sched Date] = vbblue
Else
If [Veh Code] = whatever Then
[Veh Code] and [Veh Type] = "the color you desire"
End If

You might have to use ElseIf. Other than that possibility, it should work.

Tom
 
You could use select case too
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Select Case Me.[Veh Code].Value
    Case Is = 32, 33, 82, 83, 94 Or 95
        Me.[Veh Code].ForeColor = vbGreen
        Me.[Veh Type].ForeColor = vbGreen
        Me.[Sched Date].ForeColor = vbGreen

    Case Is = 14 Or 67
        Me.[Veh Code].ForeColor = vbRed
        Me.[Veh Type].ForeColor = vbRed
        Me.[Sched Date].ForeColor = vbRed

    Case Is = 1
        Me.[Veh Code].ForeColor = vbBlue
        Me.[Veh Type].ForeColor = vbBlue
        Me.[Sched Date].ForeColor = vbBlue

    Case Else
        Me.[Veh Code].ForeColor = vbBlack
        Me.[Veh Type].ForeColor = vbBlack
        Me.[Sched Date].ForeColor = vbBlack

    End Select
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
bowieknife,
If [Veh Code] = 32, 33, 82, 83, 94, or 95 Then [Veh Code] and [Veh Type] and [Sched Date] = vbgreen

If [Veh Code] = 14 or 67 Then [Veh Code] and [Veh Type] and [Sched Date] = vbred

If [Veh Code] = 01 Then [Veh Code] and [Veh Type] and [Sched Date] = vbblue
I only count 3 expressions. Are there more? If not, then in the conditional format dialog box, select "Expression is" and enter:
[blue][Veh Code] In (32, 33, 82, 83, 94, 95)[/blue]
Then click "Add" and select "Expression is" again and enter:
[blue][Veh Code] In (14, 67)[/blue]
Then click "Add" again and select "Field value is" "equal to" and enter:
[blue]01[/blue]
Then set the formatting for each condition. You'll need to do this for each field that is to have conditional formatting applied.

Of course, if your post was just an example and there are truly more than 3 conditional expressions, then you will need to use code as the other posters have said.

HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top