4 Uses for Transparent Command Buttons in Microsoft Access

When you set a command button's Transparent property to True, you won't see it but you can still interact with it. This opens up a world of possibilities.

4 Uses for Transparent Command Buttons in Microsoft Access

Did you know that you can make your command buttons transparent?  I don't mean invisible, I mean transparent.  And, yes, there is a difference.

Invisible vs. Transparent

Ghosts are invisible.  You can't see them or touch them.

Glass is transparent.  You can't see it, but you can touch it.

The same concept applies to form controls in Access.  Every control has a Visible property.  Set it to False and the control disappears.  Like a ghost.  You can't see it or interact with it.

Like all other controls, command buttons have a Visible property.  But they also have a Transparent property.  Set it to True and the button disappears.  You can't see it, but you can still interact with it.  Like (really, really clean) glass.

This lets you do some interesting things.

Bigger mouse target areas

Consider a continuous lookup form where all the textboxes in the detail section are disabled.  In such a case, the only way to move from one record to another is to click on the record selector on the far left of the form.  That's a small target area, though.  And, as I've written in the past, small target areas make mouse-driven user interfaces more difficult to use:

Combo Boxes and Target Sizes
Just like in darts, it’s easier to hit a larger target when using the mouse. With this in mind, let’s make our combo boxes more user-friendly.

To make the entire detail section clickable, you can add a command button, resize it to fill the entire section, then set its Transparent property to True.  Now, whenever a user clicks anywhere in the detail section, the command button will be selected and activate the current record.

Take the focus

When we talk about giving a control the "focus," we are talking about making it the active control.  Not all controls can take focus.  For example, labels and rectangles cannot take focus.  Also, otherwise-editable controls like text boxes and combo boxes cannot take focus if their Enabled property is set to False.

Sometimes you may want to disable all the controls in a section, but only for certain records.  In the form's current event, you check to see if the business logic calls for the record to be locked.  If so, you could disable all the controls.  The problem is that you can't disable a control that has the focus.

This sounds like a catch-22.  What can you do?  The easiest solution is to add a small, transparent command button as a fallback control to take the focus.  You will probably want to set its Tab Stop property to False, otherwise keyboard-heavy users will notice they need to use an extra Tab to move between the two controls that appear before and after the transparent command button in the tab order.

Poor-man's image map

In HTML, an image map is where you can click on different parts of a picture and each part you click on will go to a different URL.  For example, a map of the USA could have 50 different clickable areas that correspond with each of the states.

You could implement the same concept using transparent command buttons in Access.  I call it a "poor-man's" image map, though, because the command buttons can only be rectangles.  In HTML, you can define a polygon with a series of coordinates.  This makes it much easier to provide coverage for odd-shaped image areas.

Double-click to open detail forms from a lookup form

One of my favorite things to do is combine a transparent command button with my HighlightRow function.  I use this technique to create a lookup form where the user can double-click on any portion of the detail section and my program will open the corresponding detail form for editing.

How to Highlight the Current Record in a Continuous Form
Step-by-step instructions for applying a custom highlight to the currently selected record in a continuous form in Microsoft Access.

Image by Denis Doukhan from Pixabay

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