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

Changing textbox colors on continuous forms

Status
Not open for further replies.

AWEinCA

Programmer
Oct 18, 2000
35
US
Hello!

I have continuous forms that I want to change the color of a text box. However, I don't know where to put the code.

I have tried several places but all the textboxes show up the same color on every form. I want them to be different colors depending on the date.

This is my code. Does anyone know where I need to put it to get the desired result

If (DateDiff("y", Me!DateDue.Value, Now()) > 0) Then
Me!DateDue.ForeColor = 32768 'Green
ElseIf (DateDiff(&quot;y&quot;, Me!DateDue.Value, Now()) < 0) Then
Me!DateDue.ForeColor = 32768 '255 'Red
ElseIf (DateDiff(&quot;y&quot;, Me!DateDue.Value, Now()) = 0) Then
Me!DateDue.ForeColor = 16711680 'Blue
End If

Thanks for any help you can give,
Aaron
 
Try the Format property for the DateDue field. The Format property (in Access97) can be set to 4 different values/colours. Check out the &quot;Format Property&quot; in the On-line Help.

I believe that there is a special Format colour property in Access 2000, but I haven't used 2000 much, so i'm not sure of the details. Again, the online Help should be able to give you the information.

HTH

Lightning
 
Hi,

If you are looking at continuous forms, only Access2000 is able to display a different colour depending on the value of a particular field.

If you are working with individual forms, try:

Select Case (DateDiff(&quot;y&quot;, Me!txtField.Value, Date()))
Case Is > 0
Me!txtField.ForeColor = 32768 'Green
Case Is < 0
Me!txtField.ForeColor = 255 '255 Red
Case 0
Me!txtField.ForeColor = 16711680 'Blue
End Select


as the OnCurrent event of the form property.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top