Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

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

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
amrnorman
Asked:
amrnorman
  • 3
  • 2
1 Solution
 
shanesuebsahakarnCommented:
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
 
amrnormanAuthor Commented:
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
 
shanesuebsahakarnCommented:
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
 
amrnormanAuthor Commented:
Could you provide some code for me?  Thanks.
0
 
shanesuebsahakarnCommented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now