如何有条件地在连续表单上设置文本框边框的格式? [英] How can I conditionally format textbox border on continuous form?

查看:90
本文介绍了如何有条件地在连续表单上设置文本框边框的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Access 2010中,我有一个连续的表格,我想根据另一个单元格中的值更改单元格"的某些属性,例如边框颜色.我还没有找到一种在VBA中执行此操作的方法,因为它是一种连续形式,并且直接在VBA中更改属性会更改所有记录,而不仅仅是我正在使用的记录.我假设我必须使用某种形式的条件格式,但是条件格式GUI只允许我设置背景色,基本文本格式和Enabled属性.

In Access 2010, I have a continuous form, and I'd like to change certain properties of a 'cell', like border colour, based on values in another cell. I haven't found a way to do this in VBA, because it's a continuous form and changing the properties directly in VBA changes it for all records, not just the one I'm on. I assume I have to use some form of conditional formatting, but the conditional formatting GUI only allows me to set background colour, basic text formatting, and the Enabled property.

如何在连续形式的控件上设置其他属性,仅适用于特定记录?

How can I set other properties on a control on a continuous form, for specific records only?

推荐答案

是的,您可以...只是不使用内置的条件格式设置功能. 使用表单"的详细信息"部分中的绘画"事件.仍然存在各种限制,但是至少可以设置更多的属性,而不仅仅是背景色和前景色.

Yes, you can... just not with the built-in conditional formatting functionality. Use the Paint event of the Form's Detail section. There are still various limitations, but at the least you can set more properties than just the background and foreground colors.

示例:

Private Sub Detail_Paint()
  If Me.IndicatorColumn.Value = "Critical" Then
    Detail.BackColor = RGB(255,0,0)
    Detail.AlternateBackColor = Detail.BackColor
    Me.AnotherColumn.BorderStyle = 7 'Dash Dot Dot
    Me.AnotherColumn.BorderColor = vbMagenta
  Else
    Detail.BackColor = vbWhite
    Detail.AlternateBackColor = RGB(150, 150, 150)
    Me.AnotherColumn.BorderStyle = 0 'Transparent
    Me.AnotherColumn.BorderColor = vbWhite
  End If
End Sub

请参见 TextBox.BorderStyle .

这篇关于如何有条件地在连续表单上设置文本框边框的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆