我的数据库应用程序中有一个连续的表单。在这种形式中,显示了包含3列的表的数据:product,numberofItemsOfToday,numberOfItemsOfY yesterday。
现在我希望行以红色(ForeColor)着色,如果numberofItemsOfToday!= numberOfItemsOfY在对应行中。
我试过像
这样的东西Private Sub Form_Current()
addConditionalFormatingText txtnumberofItemsOfToday, numberOfItemsOfYesterday, txtProduct, txtnumberofItemsOfToday, txtnumberOfItemsOfYesterday
End Sub
Private Sub addConditionalFormatingText(field1 As Object, field2 As Object, t1 As TextBox, t2 As TextBox, t3 As TextBox)
Dim color As Long
color = IIf(CBool(Nz(field1.Value, "") <> Nz(field2.Value, "")), RGB(255, 0, 0), RGB(0, 0, 0))
t1.ForeColor = color
t2.ForeColor = color
t3.ForeColor = color
End Sub
但当然问题是如果在一行中值不同,则所有行都用红色表示。我怎样才能以连续的形式设置特殊行的颜色?