更改根据病情行颜色 [英] Changing Row Colour according to condition

查看:691
本文介绍了更改根据病情行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的MS Access数据库管理。我有产生不同的报告seeveral链接表。我已经发现了计算器类似的问题,在这个问题上做了我的reaserach。我想根据条件(时间小于20油漆米色,2060红色)绘制行

I am using MS Access for database Administration. I have seeveral linked tables producing different reports. I have already found a similar question on stackoverflow and did my reaserach on this issue. I am trying to paint rows according to conditions (Duration <20 Paint Beige, 2060 Red)

我使用VBasic。这是我的code。

I am using VBasic. This is my code.

请让我知道你在想什么。非常感谢您的帮助!

Please let me know what you think. Many thanks for your help!

Sub ChangeBackType()

    Me.Date.BackStyle = 1
    Me.Cell.BackStyle = 1
    Me.Maintenance_Category.BackStyle = 1
    Me.Duration.BackStyle = 1
    Me.Line_Description.BackStyle = 1
    Me.Machine_Description.BackStyle = 1
    Me.Station_Number.BackStyle = 1
    Me.Fault_Description.BackStyle = 1
    Me.GM.BackStyle = 1
    Me.Remarks.BackStyle = 1
    Me.Intervention.BackStyle = 1
    Me.Technician_Name.BackStyle = 1
    Me.Shop_Floor.BackStyle = 1

End Sub

 Sub Paint_Rows_Red()

其它颜色相同的方法

'Same method for other colours

    Me.Date.BackColor = RGB(255, 29, 29)
    Me.Cell.BackColor = RGB(255, 29, 29)
    Me.Maintenance_Category.BackColor = RGB(255, 29, 29)
    Me.Duration.BackColor = RGB(255, 29, 29)
    Me.Line_Description.BackColor = RGB(255, 29, 29)
    Me.Machine_Description.BackColor = RGB(255, 29, 29)
    Me.Station_Number.BackColor = RGB(255, 29, 29)
    Me.Fault_Description.BackColor = RGB(255, 29, 29)
    Me.Intervention.BackColor = RGB(255, 29, 29)
    Me.GM.BackColor = RGB(255, 29, 29)
    Me.Remarks.BackColor = RGB(255, 29, 29)
    Me.Technician_Name.BackColor = RGB(255, 29, 29)
    Me.Shop_Floor.BackColor = RGB(255, 29, 29)

End Sub

    Private Sub Report_Load()


    ChangeBackType
     Dim Test As String

     Test = TestString2

     TestString2 = Me!Duration.Value
     TestString2 = FormatDateTime(TestString2, vbShortTime)

     If TestString2 <= CDate("00:20") Then

        Paint_Rows_Beige

     ElseIf TestString2 > CDate("00:20") And TestString2 < CDate("00:60") Then

        Paint_Rows_Orange

     ElseIf TestString2 >= CDate("00:60") Then

        Paint_Rows_Red

     End If

我想根据上述在报告中提到的条件,油漆行。有了这个code,我只获得一种颜色。

I am trying to paint rows according to the condition mentioned above in a report. With this code I am only getting one colour..

推荐答案

在具有多个行打开报表/表单,您使用code将只适用于出现在数据中的第一行。因此,在短期,你的code将无法正常工作。

When you open a report/form with multiple rows, the code you use will only apply to the first row appearing in the data. So in short, your code will not work.

然而,有使用条件格式的方式,以不同的标准色行。

There is however a way to color rows on different criteria using conditional formatting.

这篇关于更改根据病情行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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