Solved

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

Posted on 2004-09-24
5
433 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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