Highlight the Current Control in an Access Form...Without VBA!

Let's adapt Colin Riddington's excellent no-code current control highlighting technique to work with different form background colors.

Highlight the Current Control in an Access Form...Without VBA!

Colin Riddington (a.k.a., IslaDogs) posted a clever technique for highlighting the active text box or combo box on a Microsoft Access form without using any code whatsoever:

Highlight Current Control
This article describes two simple methods of highlighting the current control without requiring any code

The technique takes advantage of a bit of a quirk in Access text boxes and combo boxes.  Even when these controls have a "Transparent" Back Style, the background color becomes visible when the control has the focus.

The idea, then, is to set the background color for your text boxes and combo boxes to a highlight color while setting the background style to transparent.  This will hide the highlight color when the control does not have the focus, but display it when the control does.

  • Back Color: #FFF200
  • Back Style: Transparent

Here's what this looks like in action:

Dealing with Non-White Backgrounds

One downside of this approach is that it doesn't work as well if you use a different background color for your forms than for your text and combo boxes.

For example, here's the same form from above if we set the background color to green:

One solution to this problem is to place identically sized rectangles directly behind the text boxes and set them to your preferred text box back color, such as white (#FFFFFF).  

Here's what that technique looks like in action:

Sizing and Aligning the Rectangles

Manually sizing and aligning the rectangles would be a tedious, error-prone process.

Instead, I highly recommend taking advantage of some legacy shortcut keys to streamline the process of aligning and resizing the rectangles:

Blast From the Past
Why use keyboard shortcuts from Access 2003 when developing in 2020? Because starting with Access 2007, the new shortcuts suck.

Before we get to that, though, let's start by setting some default properties of the rectangle control on our form:

  1. Select the Rectangle control tool to change its default properties
  2. Set "Special Effect" to Flat
  3. Set "Border Style" to Transparent
  4. Set "Back Color" to #FFFFFF
  5. Set "Width" to 0.1"
  6. Set "Height" to 0.1"

With these defaults, we can click inside of our existing text boxes to create a small square rectangle that we can reliably reposition and resize.  Here are the step-by-step instructions:

  1. Select the Rectangle control tool
  2. Left-click inside the text/combo box to place a small square
  3. [Shift] + [Left-click] on the text/combo box to create a multi-control selection with both the rectangle and text/combo box
  4. [Alt] + [O], [A], [L]: align left
  5. [Alt] + [O], [A], [T]: align top
  6. [Alt] + [O], [S], [W]: resize to widest
  7. [Alt] + [O], [S], [T]: resize to tallest
  8. [Shift] + [Left-click]: deselect rectangle control (text/combo remains selected)
  9. [Alt] + [O], [R]: bring to front

Here's a screen recording of what this looks like:

All original code samples by Mike Wolfe are licensed under CC BY 4.0