Solved

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

Posted on 2004-09-24
5
392 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
  • 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now