By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

IF box is filled then change colour

P: n/a
Hi,

I have seen exampled were if value is > x then change font/colour/etc. How
would I go about doing the same except I would like it so that it changes if
there is ANYTHING in the text box.

--

Kind Regards...

Customer Services Team
Blue Bell Trading

+++ WHEN REPLYING PLEASE DO NOT DELETE ANY OF THE TEXT AS WE NEED IT FOR
REFERENCE +++

Blue Bell Trading
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
One way is to use Conditional Formatting and test against an
expression:

Not IsNull(<MyField>)

Kevin
Nick J<bl*************@blueyonder.co.uk> 5/2/2005
1:49:54 PM >>>Hi,

I have seen exampled were if value is > x then change
font/colour/etc. How
would I go about doing the same except I would like it so
that it changes if
there is ANYTHING in the text box.

--

Kind Regards...

Customer Services Team
Blue Bell Trading

+++ WHEN REPLYING PLEASE DO NOT DELETE ANY OF THE TEXT AS
WE NEED IT FOR
REFERENCE +++

Blue Bell Trading

Nov 13 '05 #2

P: n/a
in the After_Update event of your textbox you can write some code like
this:

Private Sub Text1_AfterUpdate()
If Len(Text1.Text) > 0 Then Text1.ForeColor = vbBlue
End Sub

So if a user enters some text into Text1, when the user leaves Text1,
the text content of Text1 will change to blue. There are vb color
constants (in the help files) of basic colors like black, white, yellow,
blue, red, green, cyan, magenta. You can also use colors from the
Property Sheet of the textbox (in the design view of the form). If you
pick a color for your font (ForeColor property in the textbox property
sheet) from the color grid (click on the elipses ... button to the right
of the ForeColor Property to get the color grid), the color you select
will have a numeric value in the ForeColor property like 16711680 for
blue. You can write code like this to use the color number:

Private Sub Text1_AfterUpdate()
If Len(Text1.Text) > 0 Then Text1.ForeColor = 16711680
End Sub

Using the color number gives you more variety of colors you can use.

HTH

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
I used this and it worked just dandy.

--

Kind Regards...

Customer Services Team
Blue Bell Trading

+++ WHEN REPLYING PLEASE DO NOT DELETE ANY OF THE TEXT AS WE NEED IT FOR
REFERENCE +++

Blue Bell Trading
"Kevin Nechodom" <Ke************@nospamhsc.utah.edu> wrote in message
news:d5**********@vegh.ks.cc.utah.edu...
One way is to use Conditional Formatting and test against an
expression:

Not IsNull(<MyField>)

Kevin
Nick J<bl*************@blueyonder.co.uk> 5/2/2005

1:49:54 PM >>>
Hi,

I have seen exampled were if value is > x then change
font/colour/etc. How
would I go about doing the same except I would like it so
that it changes if
there is ANYTHING in the text box.

--

Kind Regards...

Customer Services Team
Blue Bell Trading

+++ WHEN REPLYING PLEASE DO NOT DELETE ANY OF THE TEXT AS
WE NEED IT FOR
REFERENCE +++

Blue Bell Trading

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.