遇到一个问题,不知道大家是否遇到过。
实现如下的目标,部门为某值时,记录背景显示黄色。功能是实现了,但是出来之后屏幕一直在闪烁。
Private Sub Form_Open(Cancel As Integer)
setbackcolor Me.Form, "bm='设计一所' "
End Sub
Private Function setbackcolor(frm As Form, tj As String) As Boolean ‘该函数设置记录特性,从网络中获取,非常感谢!
Dim intCount As Integer
Dim ctl As Control
Dim fcd As FormatCondition
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
intCount = 0
ctl.FormatConditions.Delete
ctl.FormatConditions.Add acExpression, acEqual, tj
Set fcd = ctl.FormatConditions.Item(intCount)
With fcd
.BackColor = vbYellow '背景黄色 65535
.ForeColor = vbBlack '前景色黑色
' .FontUnderline = True '加下划线
.FontBold = True '加黑
' .FontItalic = True '斜体
End With
End If
Next ctl
setbackcolor = True
Set ctl = Nothing
Set fcd = Nothing
End Function