Highlighting focus fields

K

KevinK

I want to highlight the fields that have the focus on my form to help with
data entry. The only code I found is this:

Sub Who Has the Focus()
Dim ctl As Ccontrol
‘ First all backcolors are turned to white
For Each ctl In Me
If ctl,ControlType = acTextBox Then
EndIf
Next ctl
‘Now the currently selected Textbox backcolor is set to yellow
Me.ActiveControl.Backcolor = vbYellow
End Sub

The problem is I have a combo box mixed in, and this code only allows “vb
colorsâ€.
How can I add the combo box and more colors?
 
J

Jeanette Cunningham

Hi Kevin,
to add a combo to the current code,
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox

To find other colors, open the immediate window and type vbYellow.
While the cursor is in vbYellow, press F1 to find other colors.

There was a post just a couple of days ago with at least 3 different ways to
highlight the control that has focus.
I will look for it and post it here when I find it.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

Jeanette Cunningham

No success in finding that post I mentioned in my last post.
Here are some more options:

You can give all controls that edit data a color that will stand out against
the backcolor of the form. Make those controls transparent. When a control
has focus, it will become normal instead of transparent. When user moves off
the control it becomes transparent again.


You can use conditional formatting. Select all the editable controls, hit
conditional formatting and choose 'Field Has Focus' and set the color.

There is some code here to highlight focus fields
http://www.allenbrowne.com/highlight.html



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top