Link to home
Start Free TrialLog in
Avatar of amrnorman
amrnorman

asked on

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
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of amrnorman
amrnorman

ASKER

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.
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.
Could you provide some code for me?  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial