0

I have created a database in Access. This is how I set my workflow.

  1. Created 'fields' table.
  2. Gave each field their unique column name (ie. Project Team field has Fld10078 field ID)
  3. Created 'ticket' form
  4. Produced report that has a 'ticket' card looking layout with desired fields layed at desired place.
  5. Each project team on the 'ticket' has their own color.

Before I came, this was already coded and was working fine. Each project team has its own unique color. I wanted to add 2 new teams with their unique colors but it's now showing up. Only the first 4 teams would show color on ticket card.

Here's the code:

Select Case Me.Fld10078

        Case "Team A"
            Me.Fld10078.BackColor = RGB(204, 0, 0)
            Me.Fld10078.ForeColor = vbWhite
        Case "Team B"
            Me.Fld10078.BackColor = RGB(51, 102, 255)
            Me.Fld10078.ForeColor = vbWhite
        Case "Team C"
            Me.Fld10078.BackColor = RGB(0, 153, 0)
            Me.Fld10078.ForeColor = vbWhite
        Case "Team D"
            Me.Fld10078.BackColor = RGB(255, 153, 0)
            Me.Fld10078.ForeColor = vbWhite
        Case "Team E"
            Me.Fld10078.BackColor = RGB(204, 0, 0)
            Me.Fld10078.ForeColor = vbWhite
        Case "Team M"
            Me.Fld10078.BackColor = RGB(0, 128, 128)
            Me.Fld10078.ForeColor = vbWhite
        Case Else
            Me.Fld10078.Visible = False
    End Select

Here's what I have for control source:

=IIf([Fld10078]="Team A","Team A",IIf([Fld10078]="Team B","Team B",IIf([Fld10078]="Team C","Team C",IIf([Fld10078]="Team D","Team D",IIf([Fld10078]="Team E","Team E",IIf([Fld10078]="Team M","Team M"))))))

Team E and Team M are not showing colors. They are showing text but not colors.

4

1 回答 1

0

如果控件的名称与数据库字段名称相同,则 Access 有时会感到困惑。

尝试将标签 Fld10078 重命名为其他名称,例如 TeamLabel 或 lblFld10078。使用属性 (F4)、所有选项卡、名称属性。

编辑以澄清评论

假设Fld10078是列名,并且lblFld10078是引用它的标签,请执行以下操作:

  • 在 Select Case 语句之前设置 lblFld10078.Visible = True
  • 将 IIf 语句的 Caption 属性更改 lblFld10078为 =[Fld10078]
于 2013-09-30T20:38:03.413 回答