Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2000 - On GotFocus: Change Color of CheckBox Control on Form

Posted on 2004-09-24
5
Medium Priority
?
446 Views
Last Modified: 2008-03-17
Hello,

I have a module with the following code that changes the color of text boxes when the user has placed focus on them.  I want to do the same with checkboxes.  Actually any kind of highlighting would be great.  I know that as one tabs through controls on a form, there is a "box" that forms around each control with focus automatically.  However, the border is very faint and difficult to see.  Is my request doable?  Please provide the code.  Thanks.

Here is the code in my existing module:

Option Compare Database

Function Highlight(Stat As String) As Integer
Dim ctrl As Control
On Error Resume Next
Set ctrl = Screen.ActiveControl
If Stat = "GotFocus" Then
    ctrl.BackColor = 65535
ElseIf Stat = "LostFocus" Then
    ctrl.BackColor = 16777215
End If
End Function
0
Comment
Question by:amrnorman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12145186
You can't change the colour of a checkbox, but what I normally do is place the checkbox on to a coloured rectangle and change the colour of the rectangle.
0
 

Author Comment

by:amrnorman
ID: 12147204
How to I do the code for the rectangle?  The event options are onClick, on Dbl Click, on Mouse Down, on Mouse Move, and on Mouse Up.  I need to have the color change on Got Focus and on Lost Focus.  Thanks.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12147220
Just change the colour of the rectangle in the GotFocus event of the *checkbox*. You may need to write a separate generic function to do this, of course.
0
 

Author Comment

by:amrnorman
ID: 12147753
Could you provide some code for me?  Thanks.
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 1500 total points
ID: 12147783
Well, it's pretty much the same as your existing code. Just this in the GotFocus event of the checkbox:

Me!MyRectangle.BackColor=65535

and this in the LostFocus of the checkbox:
Me!MyRectangle.BackColor=16777215
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question