I have a problem with BackColor

nilses

Registered User.
Local time
Today, 19:49
Joined
Jan 2, 2003
Messages
45
Hello,

I have a problem with property BackColor. I would like to put the back color (by code VBA and not by the option of formating) according to the value of a field but I do not arrive there in spite
of my many test and my research. Could you help me.

I have do this like function:

' This function doesn' t run and I don' t No why!!!!
Private Sub Report_Page()
If Me![Type ] = "5260" Then
Me![Type].BackColor = RGB(0, 25, 255)
Else Me![Type].BackColor = RGB(0, 0, 255)
End if
End Sub

I wanted to put in Excel my state in Excel and it does not keep the colors during the transfer, is this normal?.


Thank you for your assistance

Nilses
 
Niles,

It is not a function if it has Private_Sub

Private Sub Report_Page()
If Me![Type] = "5260" Then
Me![Type].BackColor = RGB(0, 25, 255)
Else
Me![Type].BackColor = RGB(0, 0, 255)
End if
End Sub


Useful Example

Sub Form_Current()
Dim curAmntDue As Currency, lngBlack As Long
Dim lngRed As Long, lngYellow As Long, lngWhite As Long

If Not IsNull(Me!txtPastDue.Value) Then
curAmntDue = Me!txtPastDue.Value
Else
Exit Sub
End If
lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
If curAmntDue > 100 Then
Me!txtPastDue.BorderColor = lngRed
Me!txtPastDue.ForeColor = lngRed
Me!txtPastDue.BackColor = lngYellow
Else
Me!txtPastDue.BorderColor = lngBlack
Me!txtPastDue.ForeColor = lngBlack
Me!txtPastDue.BackColor = lngWhite
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom