Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing txt box colors 1

Status
Not open for further replies.

Ben6550

Technical User
Jan 8, 2004
16
0
0
GB
I want a sub which will change the background color of a text box when a check box has been clicked. However when i click the check box the text box for all the records change color when i only want a single record to change. How can i get around this.

Code is:

Private Sub employed_Click()
ColorTextBox
End Sub


Private Sub ColorTextBox()

If employed Then
Notes_Label.BackColor = vbRed
Else
Notes_Label.BackColor = vbWhite
End If

End Sub
 
As far as I know conditional formatting is not possible.

There is a workaround for this problem. But then this will change only forecolor.

Have 2 fields (not labels)one with red and other white foreground.One on top of the other
The controlsource for the fields will be
= iif(employed, "Name","")
= iif(employed, "","Name") respectively

Then
Private Sub employed_Click()

Notes_Label1.requery:Notes_Label2.requery

End Sub

Best of luck



 
If you are using A2k or above then you can use conditional formatting.
Just select your textbox then choose conditional formatting from the format menu and set the expression to:
[check0]=True (where check0 is the name of your checkbox) and set the format you want the text box to have.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Thanks Ben, this works just great. I can think of a few otehr places in my db where this can be put to use.

TechieJr.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top