0

我的数据库应用程序中有一个连续的表格。在这种形式中,显示了具有 3 列的表的数据:product、numberofItemsOfToday、numberOfItemsOfYesterday。

现在,如果相应行中的 numberofItemsOfToday != numberOfItemsOfYesterday ,我希望将行着色为红色(ForeColor)。

我尝试了类似的东西

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

但当然问题是,如果某一行中的值不同,则所有行都被涂成红色。如何只以连续形式设置特殊行的颜色?

4

0 回答 0