Changing the BackColor of a label, box or textbox via code

A

Alp Bekisoglu

Hi Experts,

Is it possible to manipulate the background of a label, box or textbox based
on the value of a variable at runtime in a report? Well, actually
sub-report...

Thanks in advance.

Alp
 
D

Duane Hookom

You may be able to use Conditional Formatting to set display properties.
Otherwise, you can use the On Format event of the section containing the
control like:
If Me.txtSomeValue < 100 Then
Me.lblMyLabel.BackColor = vbRed
Else
Me.lblMyLabel.BackColor = vbGreen
End If
 
A

Alp Bekisoglu

Hi Duane,

Thanks for your advice. I have tried the following without any success
before I wrote to the group.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Label36.Visible = False
Me.w_dt.Visible = False
Me.Label74.BackColor = 16777215
Me.Label75.BackColor = 16777215
If Me.a_y > 2002 Then
Me.Label74.BackColor = 14015937
Me.Label75.BackColor = 14015937
End If
If Me.w_a = "WH" Then Me.Label36.Visible = True And Me.w_dt.Visible = True
End Sub

The second "If" works but the one to change the color does not no matter
what I try and I can't figure out why.

Any ideas?

Alp
 
A

Alp Bekisoglu

Duane, I found it (finally!). They were set as "Transparent". I thought
setting a color would override that setting.

Well, one more thing learned.

Thanks for your help.

Alp
 
Top