We help IT Professionals succeed at work.
Get Started

Clean way to change forecolor and backcolor of a textbox (MouseOver)

Sean Strickland
Last Modified: 2013-11-28
I'm looking for a clean way to change the fore/back colors of a textbox in Access 97 using the MouseOver event.  Is there some quick code that someone can give me that would allow me to "highlight" boxes using this event.  I'm looking for a way to maybe use a Public Function and pass the variable that is currently under the mouse through it.

I'm thinking in the MouseOver event, you have some code that says:

And the ChangeColor function would check to make sure that it's a Text Box, and maybe check to see if there is a stored variable in the tag property?

I'm not really sure, I just want the control to change backcolor when it's hovered onto, and revert back when it loses the mouses' focus.

I've been using something similar to the following to do this, but don't want to do it for every control that I put on the form:

Private Sub txtName_MouseOver()
Me.txtName.BackColor = vbWhite
End Sub
Private Sub txtNumber_MouseOver()
Me.txtNumber.BackColor = vbWhite
End Sub
Private Sub Detail_MouseOver()
Me.txtName.BackColor = vbRed
Me.txtNumber.Backcolor = vbRed
End Sub

Open in new window

Watch Question
Database Developer
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE