条件格式化Access 2010代码

时间:2014-09-09 08:48:31

标签: vba ms-access access-vba ms-access-2007

我不知道为什么表格没有向我显示格式条件。我只能通过代码使用它。我无法以通常的方式进行格式化。我在Form_Load中调用此函数。

Function ControllaColori()
    Dim i As Integer
    Dim Formatta As FormatConditionI
    m_Anno = Anno
    m_Mese = Mese

    Forms("PresenzeOspite").Controls("tg1").FormatConditions.Delete

    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.Add(acFieldValue, acEqual, "A")
    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.Add(acFieldValue, acEqual, "P")
    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.Add(acFieldValue, acEqual, "H")

    With Forms("PresenzeOspite").Controls("tg1").FormatConditions(0)
        .BackColor = RGB(255, 0, 0)
        .FontBold = True
    End With

    With Forms("PresenzeOspite").Controls("tg1").FormatConditions(1)
        .BackColor = RGB(127, 255, 0)
        .FontBold = True
    End With

    With Forms("PresenzeOspite").Controls("tg1").FormatConditions(2)
        .BackColor = RGB(248, 248, 255)
        .FontBold = True
    End With

    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.item(0)
    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.item(1)
    Set Formatta = Forms("PresenzeOspite").Controls("tg1").FormatConditions.item(2)
    Set Formatta = Nothing
End Function

使用此代码Forms("PresenzeOspite").Controls("tg1").FormatConditions.Delete我们可以删除现有条件,但是当我们尝试使用前面的代码添加新条件时,在调试中,我可以从对象中获取条件,但它不会被显示在运行时来自

0 个答案:

没有答案