Change Background Color of Text Boxes and Command Buttons

G

Guest

Hello,

I have access 2003. I have a form with text boxes and command buttons. I
want to set it up that when you're on a particular text box or command
button, that it turns a different color so it's real apparent what field you
on.

I think I figured out how do achieve this for text boxes using the following
code:

Private Sub Subject_GotFocus()
Me.Subject.BackColor = 8454143
End Sub

Private Sub Subject_LostFocus()
Me.Subject.BackColor = 16777215
End Sub

Can anyone assist me help me with the command buttons. I don't even know
how to change their background color, only their font color.

Thanks in advance.
 
M

Marshall Barton

LDMueller said:
I have access 2003. I have a form with text boxes and command buttons. I
want to set it up that when you're on a particular text box or command
button, that it turns a different color so it's real apparent what field you
on.

I think I figured out how do achieve this for text boxes using the following
code:

Private Sub Subject_GotFocus()
Me.Subject.BackColor = 8454143
End Sub

Private Sub Subject_LostFocus()
Me.Subject.BackColor = 16777215
End Sub

Can anyone assist me help me with the command buttons. I don't even know
how to change their background color, only their font color.


Command buttons do not have a BackColor so it can not be
changed using using standard Access features.

What I usually do is place a rectangle control behind the
button. Size the box to leave a relatively small border
around the button. Then set the rectangle's BackColor.

An alternative is to use a label or text box control instead
of a button. There are complications though. Labels can
not receive the focus so you can not tab to them, you must
use the mouse. With a text box, you have to use an
expression to display the equivalent of the caption so as to
prevent users from typing in the text box. Neither of them
will vertically center their text and you need to use the
MouseDown and MouseUp events to change the SpecialEffect.

OTOH, If you don't mind all the code involved, command
button color can be changed by using API calls. Check
www.lebans.com for this solution.
 
G

Guest

Command buttons do not have a backcolor property.
I think there might be something on Steve Leban's web site that does some
trickery on this:
www.lebans.com
 
M

missinglinq via AccessMonster.com

Or you could either make the text bold when the command button has focus, or
change the color of the text, or both!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top