Private Sub Form_Load()
'sfrChild是子窗体控件的名称,me.sfrChild.Form即代表子窗体
SetMyFormat Me.sfrChild.Form, "完成率 < 0.8"
End Sub
Function SetMyFormat(frm As Form, tj As String) As Boolean
'修改正王樵民老师示例中的函数
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 = 255 '背景色红色
.ForeColor = 0 '前景色黑色
End With
End If
Next ctl
SetMyFormat = True
Set ctl = Nothing
Set fcd = Nothing
End Function
这是原代码,请问在哪里修改?想得出上图中的效果。谢谢!