DETAIL COLOR TEXT BOX CHANGE (1 Viewer)

sbornstein1

Registered User.
Local time
Today, 23:10
Joined
Jun 19, 2001
Messages
24
Hello all. I need your help I need to change the backcolor of text boxes based on a date. Now I have this code but it needs to somehow know to change in the DETAIL section of the form which loops of course through the recordsource.
Dim bg as Long
Dim dt as Date ' this is so there is only 1 function call to Date routine

dt = Date
If Me![OrderDate] =dt Then
bg=vbyellow
ElseIf Me![OrderDate] < dt then
bg = vbwhite
Else
bg = 14540253
End If

ANY IDEAS? THANKS
 

D-Fresh

Registered User.
Local time
Today, 23:10
Joined
Jun 6, 2000
Messages
225
Try this to change the color of all text boxes in your form... Put the code in a On Click of a command button or an AfterUpdate or whatever event you choose...


Dim ctl As Control

For Each ctl In Controls
If ctl.ControlType = acTextBox Then
ctl.BackColor = vbYellow
End If
Next

you can put each For Each ctl loop into the procedures of your if statement... Hope that helps...

Doug
 

sbornstein1

Registered User.
Local time
Today, 23:10
Joined
Jun 19, 2001
Messages
24
Thanks for the reply Doug. The problem I am having is that I have a row that is in my DETAIL section of the form. The color does change but only for the first condition. So for example lets say orderdate is < currentdate that changes it to white and then all the rows change to white not for each time.
 

Users who are viewing this thread

Top Bottom