今天在网站找到一个比较好的东东,自己研究了一下,现在将我实现的效果和大家分享一下!!
图 示:
具体代码如下:
Dim ctl As Control
Dim rst As DAO.Recordset
Dim str As String
Set rst = Me.sfrList.Form.RecordsetClone
If rst.RecordCount > 0 Then rst.MoveFirst
Do Until rst.EOF
If DCount("*", "TMP_牛群转群日期", "乳牛号='" & rst!乳牛号 & "'") > 1 Then
str = str & "乳牛号='" & rst!乳牛号 & "' or "
End If
rst.MoveNext
Loop
If Len(str) > 0 Then
str = Left(str, Len(str) - 4)
End If
For Each ctl In Me.sfrList.Form
If ctl.ControlType = acTextBox or ctl.ControlType = acComboBox Then
ctl.FormatConditions.Add acExpression, acEqual, 1
ctl.FormatConditions(0).Modify acExpression, , str
ctl.FormatConditions(0).BackColor = vbRed
End If
Next