Conditional Formatting based on another field

  • Thread starter Thread starter Darhl Thomason
  • Start date Start date
D

Darhl Thomason

I want to be able to conditionally format a txtBox on my report based on the
value of a yes/no field in my db. The txtBox shows a date and the yes/no is
to say if the date has changed. If the date has changed, I want the
background of the txtBox to be yellow, otherwise I want it to be white
(transparent actually).

Here is my code (note, I get the value of InstallDateChanged and
OpenDateChanged in the recordsource for the report.:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If tblStoreData.InstallDateChanged = True Then
Me.txtInstallDate.BackColor = vbYellow
Else
Me.txtInstallDate.BackColor = vbWhite
End If
If tblStoreData.OpenDatechanged = True Then
Me.txtOpenDate.BackColor = vbYellow
Else
Me.txtOpenDate.BackColor = vbWhite
End If
End Sub

Thanks!

Darhl
 
okay, you wrote the code - do you have a question or problem? is the code
not working? if so, what's happening? is it erring out? if so, on what line
of code?
 
Darhl said:
I want to be able to conditionally format a txtBox on my report based on the
value of a yes/no field in my db. The txtBox shows a date and the yes/no is
to say if the date has changed. If the date has changed, I want the
background of the txtBox to be yellow, otherwise I want it to be white
(transparent actually).

Here is my code (note, I get the value of InstallDateChanged and
OpenDateChanged in the recordsource for the report.:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If tblStoreData.InstallDateChanged = True Then
Me.txtInstallDate.BackColor = vbYellow
Else
Me.txtInstallDate.BackColor = vbWhite
End If
If tblStoreData.OpenDatechanged = True Then
Me.txtOpenDate.BackColor = vbYellow
Else
Me.txtOpenDate.BackColor = vbWhite
End If
End Sub


The yes/no field needs to be bound to a control on then
report. Then the If statements should refer to the bound
control:
If Me.chkInstallDateChanged = True Then
 
Thanks Marsh, that was the deal. Then I made the .visible property of the
chkBoxes to false so I don't see them on the report and it works like a
champ!

Your help is always highly appreciated.

Darhl
 
Back
Top