Set Control colors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my report, I'm trying to set the border color, fore color & back color of
the EDSDisplay control depending on the value of the EDS control. I've tried
to change the below code a few different ways and I either get an error
message or it comes up with the wrong color. Any idea what I'm doing wrong.

Thank you

Private Sub Report_Open(Cancel As Integer)

Dim EDS As Integer
Dim EDSDisplay As Integer
Dim lngBlack As Long
Dim lngRed As Long, lngYellow As Long, lngWhite As Long
Dim lngGreen As Long

If Not IsNull(Me!EDSDisplay.Value) Then
EDS = Me!EDSDisplay.Value
Else
Exit Sub
End If

lngRed = RGB(255, 0, 0)
lngGreen = RGB(0, 255, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
lngBlack = RGB(0, 0, 0)


If EDS > 0 Then
Me!EDSDisplay.BorderColor = lngGreen
Me!EDSDisplay.ForeColor = lngBlack
Me!EDSDisplay.BackColor = lngGreen
ElseIf EDS = 3 Then
Me!EDSDisplay.BorderColor = lngRed
Me!EDSDisplay.ForeColor = lngBlack
Me!EDSDisplay.BackColor = lngRed
ElseIf EDS = 0 Then
Me!EDSDisplay.BorderColor = lngYellow
Me!EDSDisplay.ForeColor = lngBlack
Me!EDSDisplay.BackColor = lngYellow
Else
Me!EDSDisplay.BorderColor = lngGreen
Me!EDSDisplay.ForeColor = lngBlack
Me!EDSDisplay.BackColor = lngGreen
End If
End Sub
 
If you can tell me how to conditionally make the border color the same color
as the backgroud then I'd be more than happy to use conditional formatting.
But, I'm putting several contols side by side and there is a white border
around them, regardless of the color when I use conditional formatting.
 
Set the BorderStyle to Transparent instead of Solid. If you are going to
change the display properties of the controls in a Report, you need to do it
within the Format Event of the control's section (probably Detail_Format() )

HTH,

Kevin
 
Back
Top