要求:子窗体控件单位名称获得焦点背景显示为黄色,字体加粗,控件单位类型的值为“客户”时,背景色显示为红色并字体加粗,单位类型的值为"供应商"时,背景色显示为蓝色并字体加粗,单位类型的值为"外加工单位"时,背景色显示为绿色并字体加粗。
图 示:
代码如下:
'条件格式基于窗体上具有焦点的控件的值(单位名称获得焦点背景色就变为黄色,字体加粗)
With Me.frmchild.Form!单位名称.FormatConditions.Add(acFieldHasFocus)
.BackColor = RGB(210, 210, 70)
.FontBold = True
End With
'条件格式基于表达式(单位类型为不同值的话显示不同的背景色,字体加粗)
With Me.frmchild.Form!单位类型.FormatConditions.Add(acExpression, , "[单位类型] = '供应商'")
.BackColor = RGB(102, 102, 255) '蓝色
.FontBold = True
End With
With Me.frmchild.Form!单位类型.FormatConditions.Add(acExpression, , "[单位类型] = '客户'")
.BackColor = RGB(255, 0, 0) '红色
.FontBold = True
End With
With Me.frmchild.Form!单位类型.FormatConditions.Add(acExpression, , "[单位类型] = '外加工单位'")
.BackColor = RGB(112, 223, 73) '绿色
.FontBold = True
End With
Me.frmchild.Requery
附 件:
下载该示例附件