Expert helps needed!! Continuous forms and change color when data changes. pls help!

metad

Registered User.
Local time
Today, 15:13
Joined
Oct 14, 2004
Messages
28
Hi. I use MS Access 2002 and I have a database with 2 forms, one in continuous view. I want to change background colors (or text colors) when a field “ActionTime” is closed to the actual time. I have studied a lot of threats here, but still I have problems to make it works.

To test the functionality, I have used the following code:

Private Sub Form_Current()
If Me.GateArea = "2" Then
Me.GateArea.BackColor = vbBlue
Me.Destination.BackColor = vbBlue
(More fields)
Else
Me.GateArea.BackColor = vbRed
Me.Destination.BackColor = vbRed
(More fields)
End If
End Sub

This works fine in normal form view, but not in continuous view.

I know to use the conditional format, but this will only work for one field. I want to change the color of all fields on the current record based on changes on ActionTime.

Second question is how to code the data change. ActionTime is based on clock. I have used the following code, but it seems it is wrong somewhere:

If(DateDiff("n", [ActionTime]< Now()+10) Then
Me.GateArea.BackColor = vbBlue
Me.Destination.BackColor = vbBlue
(More fields)
Else
Me.GateArea.BackColor = vbRed
Me.Destination.BackColor = vbRed
(More fields)
End If
End Sub

Thanks in advance for any help.
 
metad,

Conditional Formatting is not restricted to one field. Select the field that
you want and then go to Conditional Formatting.

You were making the second part sort of like an IIf statement:

If(DateDiff("n", [ActionTime], Now()) < 10 Then
Me.GateArea.BackColor = vbBlue
Me.Destination.BackColor = vbBlue
(More fields)
Else
Me.GateArea.BackColor = vbRed
Me.Destination.BackColor = vbRed
(More fields)
End If

Wayne
 
WayneRyan said:
metad,

Conditional Formatting is not restricted to one field. Select the field that
you want and then go to Conditional Formatting.

Metad is probably talking about using Conditional Formatting on the whole row based on the value of one field of that row.

giedrius
 
You can use conditional formatting on the whole row,I answered this only a short while ago, just select the row and use the formula construct.

Brian
 
Thnay you. Solved

Hi agian, and thank you for your tips.

Yes, I was talking about using Conditional Formatting on the whole row based on the value of one field of that row. I marked the hole row and then used the following condition, and everything is working:

DateDiff("n";Now();[ActionDate] & " " & [ActionTime])<20

Thank you for your help!
Metad
 

Users who are viewing this thread

Back
Top Bottom