Changing the colour of fields (1 Viewer)

C

Chris

Guest
I am developing a front end for our database of our customers. I use a continuos subform to display them after a search, but I would like them to be green if the company is registered, and another colour if not. I have seen this done before and is really easy to do in 2000, but I can't figure it out in 97. Also could you please tell me\suggest where the relevant piece of code goes. Many thanks in advance.
 

Loz

New member
Local time
Today, 08:57
Joined
Nov 29, 1999
Messages
6
Try this code in the OnCurrent.
It was used for another application, but you should be able to derive your requirements.

<snip>
Private Sub Form_Current()
' set colour of background depending on live or decomissioned

Const ltblue = 16776960
Const ltgreen = 65280
Const red = 255

If Me.Decomissioned.Value = -1 Then
Me.FormHeader.BackColor = ltblue
Me.Detail.BackColor = ltblue
ElseIf Me.Ghost = -1 Then
Me.Detail.BackColor = red
Me.FormHeader.BackColor = red
Else
Me.Detail.BackColor = ltgreen
Me.FormHeader.BackColor = ltgreen
End If

End Sub
<end snip>

Best of luck
LOZ
 
C

Chris

Guest
Thanx for the snips. I have put the code into the place you have suggested, and ammended the code a bit for my needs, however. It will only change colour when I select a record, but, every one in the subform changes to either red or green. The clause is just a simple "IsNull". Sorry to have hassled you. But thanks very much for the help so far. I'm certainly a step further to a finished database.
 

Users who are viewing this thread

Top Bottom