Conditional Formatting to a text box

qnikchen

Registered User.
Local time
Today, 05:53
Joined
May 2, 2013
Messages
13
Hi Guys,

I am working with a form, where it displays several text boxes that I would like to display certain colors depending on the value. My form is a single form. One name of the text boxes is Text27, and I am using access 2007. I have been searching on the internet, and I have found that VBA will work. I don't know anything at all about VBA in Access (Only a soso with excel). Please, help me to figure out how I could add the following conditions in a text box from a form. Please let me know where I do need to add the code. Again, I am a novate with access' VBA


If x<-0.05 = background = orange; letter = white
If 0.05>x>-0.05 = background = green; letter = white
If 0.05>x>0.10 = background = orange; letter white
If x>10 = background = red; letter = white

I have tried with some search on the internet and I kinda tried to play with it, and I have found/got this: (The color might not be right) and I dont know how to use.

If Me.Text27 > -0.05 And Me.Text27 < 0.05 Then
Me.Text27.BackColor = RGB(50, 205, 50)
ElseIf Me.Text27 > 0.05 And Me.Text27 < 0.1 Then
Me.Text27.BackColor = RGB(255, 0, 0)
ElseIf Me.Text27 > 0.1 Then
Me.Text27.BackColor = RGB(160, 32, 240)
ElseIf Me.Text27 > -0.05 Then
Me.Text27.BackColor = RGB(135, 206, 250).

Please any help or suggestion would be very appreciatted.

Thank you in advance
 
I think that the code you have should work if you put it in the On Current event of the form and also in the After Update event of the text box.
You will need to add an "End If" at the end of the code though.
 

Users who are viewing this thread

Back
Top Bottom