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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format color detail if No selection 1

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
Hi. I have this code in my report to make Status an actual color. It works just fine. However, sometimes there will be NO status. How do I code to leave white or blank if no status is selected?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me.Status
Case "Red"
Me.Status.BackColor = vbRed
Me.Status.ForeColor = vbRed
Case "Green"
Me.Status.BackColor = vbGreen
Me.Status.ForeColor = vbGreen
Case "Yellow"
Me.Status.BackColor = vbYellow
Me.Status.ForeColor = vbYellow
End Select

End Sub
 
Hm - I don't know which is appropriate, but perhaps either

[tt]Select Case Me.Status
Case "Red"
Me.Status.BackColor = vbRed
Me.Status.ForeColor = vbRed
Case "Green"
Me.Status.BackColor = vbGreen
Me.Status.ForeColor = vbGreen
Case "Yellow"
Me.Status.BackColor = vbYellow
Me.Status.ForeColor = vbYellow
Case Else
Me.Status.BackColor = vbWhite
Me.Status.ForeColor = vbWhite
End Select[/tt]

or

[tt]if trim(me!status & "") ="" then
Me.Status.BackColor = vbWhite
Me.Status.ForeColor = vbWhite
else
Select Case Me.Status
Case "Red"
Me.Status.BackColor = vbRed
Me.Status.ForeColor = vbRed
Case "Green"
Me.Status.BackColor = vbGreen
Me.Status.ForeColor = vbGreen
Case "Yellow"
Me.Status.BackColor = vbYellow
Me.Status.ForeColor = vbYellow
End Select
end if[/tt]

Roy-Vidar
 
Thanks a lot RoyVidar. Case Else worked perfectly!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top