PC Review


Reply
Thread Tools Rate Thread

back color of label after update

 
 
=?Utf-8?B?Y2hhcmxvdHRl?=
Guest
Posts: n/a
 
      24th Feb 2006
I would like to cause the back color of the label of a combo box on a form to
change color after selecting one of two choices: 'sold' and 'unsold'. I have
tried to write an event procedure but am new to vba and have had no success.
I would very much like some advice
--
charlotte
 
Reply With Quote
 
 
 
 
Brendan Reynolds
Guest
Posts: n/a
 
      24th Feb 2006

Don't forget to set the BackStyle property of the label - the default is
Transparent, and changing the BackColor property of a Transparent label has
no visible effect. In the example below, I've set the BackColor property in
the AfterUpdate event of the combo box, and also in the Current event of the
form, so that it will change as the user browses through records. I've set
the properties of the combo box programmatically in the Load event of the
form, but you don't have to do it that way. You can set them using the
Properties window at design time. I did it programmatically just for
illustration, so that you can see everything in one place.

Private Sub Combo0_AfterUpdate()

Select Case Me.Combo0
Case "One"
Me.Label1.BackColor = vbRed
Case "Two"
Me.Label1.BackColor = vbBlue
Case Else
Me.Label1.BackColor = vbYellow
End Select

End Sub

Private Sub Form_Current()

Select Case Me.Combo0
Case "One"
Me.Label1.BackColor = vbRed
Case "Two"
Me.Label1.BackColor = vbBlue
Case Else
Me.Label1.BackColor = vbYellow
End Select

End Sub

Private Sub Form_Load()

Me.Combo0.RowSourceType = "Value List"
Me.Combo0.RowSource = "One;Two;Three"
Me.Label1.BackStyle = 1

End Sub

--
Brendan Reynolds
Access MVP


"charlotte" <(E-Mail Removed)> wrote in message
news:8F18E2CD-9794-40C2-A772-(E-Mail Removed)...
>I would like to cause the back color of the label of a combo box on a form
>to
> change color after selecting one of two choices: 'sold' and 'unsold'. I
> have
> tried to write an event procedure but am new to vba and have had no
> success.
> I would very much like some advice
> --
> charlotte



 
Reply With Quote
 
=?Utf-8?B?cmhhbm4=?=
Guest
Posts: n/a
 
      24th Feb 2006
Private Sub Text63_AfterUpdate()
If Text63.Text > 7 Then Text63.BackColor = 4194432 Else
If Text63.Text > 15 Then Text63.BackColor = 12632256 Else
If Text63.Text > 19 Then Text63.BackColor = 65535 Else
If Text63.Text = 34 Then Text63.BackColor = 16711808
End If
that will do a similar job
cahnge the text files and the greater statement and it should work

"charlotte" wrote:

> I would like to cause the back color of the label of a combo box on a form to
> change color after selecting one of two choices: 'sold' and 'unsold'. I have
> tried to write an event procedure but am new to vba and have had no success.
> I would very much like some advice
> --
> charlotte

 
Reply With Quote
 
tina
Guest
Posts: n/a
 
      24th Feb 2006
if the form is in SingleForm view (shows one record at a time), run the code
from the combo box's AfterUpdate event, and the form's Current event, as

If Me!ComboBoxName = "sold" Then
Me!LabelName.BackColor = vbGreen
Else
Me!LabelName.BackColor = vbRed
End If

you can use any of the VB color constants, or you can use a numeric value to
display any shade of any color you choose.

note that if your form is set to ContinuousForms view, the code will act
according to the control's value in the current record, but will change the
label color in every rcord displayed in the form. if you're using A2000 or
newer, you can get around that by changing the label to an unbound textbox
control, and using the Conditional Formatting option, found in form design
view under Format on the menu bar.

hth


"charlotte" <(E-Mail Removed)> wrote in message
news:8F18E2CD-9794-40C2-A772-(E-Mail Removed)...
> I would like to cause the back color of the label of a combo box on a form

to
> change color after selecting one of two choices: 'sold' and 'unsold'. I

have
> tried to write an event procedure but am new to vba and have had no

success.
> I would very much like some advice
> --
> charlotte



 
Reply With Quote
 
=?Utf-8?B?Y2hhcmxvdHRl?=
Guest
Posts: n/a
 
      24th Feb 2006
Thanks for all your help
--
charlotte


"charlotte" wrote:

> I would like to cause the back color of the label of a combo box on a form to
> change color after selecting one of two choices: 'sold' and 'unsold'. I have
> tried to write an event procedure but am new to vba and have had no success.
> I would very much like some advice
> --
> charlotte

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Label Reverts Back to Default Font Size / Color Nora Microsoft Powerpoint 0 30th Apr 2010 06:56 PM
Back color on Label control =?Utf-8?B?TWFuaXNo?= Microsoft Dot NET Compact Framework 2 3rd Oct 2006 10:41 AM
adding a new color label to the label list for Microsoft Outlook 2 =?Utf-8?B?Q1NTIFRlY2g=?= Microsoft Outlook Calendar 1 21st Jul 2006 04:57 PM
Is it possible to put a label with a transparent back color on a form? Peter Microsoft VB .NET 5 20th Nov 2005 10:26 AM
Can't get my costom background color back after windows update. =?Utf-8?B?U2xhcHB5IFBhcHB5?= Windows XP Internet Explorer 1 12th Feb 2004 02:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 AM.