Quick Tip: 4 Ways to Select the Bottom Control in a Stack
There are several situations where you may find yourself with multiple controls stacked on top of each other on a Microsoft Access form or report:
- Transparent command buttons
- Current row highlighting
- The combo box/text box trick
- Controls where you use code to set
.Visible
toTrue
for one andFalse
for the other
When the two controls are the exact same size and in the exact same position, it may seem impossible to select the bottom control in the z-order. However, there are a few different ways you can do it.
Sample Form
In each example below, we're using a simple form with only two controls:
- A textbox named
Text0
- A command button named
Command1
withTransparent = Yes
The two controls are the same size and occupy the same position on the form. The command button, Command1
, sits above the text box in the z-order.
In each option below, our goal is to select the text box (which is under the transparent command button).
Option 1: Using the Property Sheet Dropdown
If you know the name of the control you want, you can select it from the Property Sheet dropdown control.
If the Property Sheet pane is not visible, you can turn it on via the ribbon (Form Design > Tools > Property Sheet) or via its shortcut key [F4].
Option 2: Temporarily Switch the Z-Order
Sometimes you don't know the name of the control you want. Or maybe there are so many controls on the form or report that it's inconvenient to search through the dropdown list for the one you want.
With this option you:
- Right-click the top control (
Command1
) - Select Position > Send to Back
- Left-click the new top control (
Text0
) - Make whatever changes to the control you need to
- Right-click the new top control (
Text0
) - Select Position > Send to Back
I don't love this option. It's a fair amount of extra steps AND you need to be careful to remember to restore the proper z-order of your controls.
Don't worry, there's a better way.
Option 3: Temporarily Resizing the Top Control
This is very similar to the above option. Instead of changing the control's z-order, we change its size or position.
- Left-click the top control (
Command1
) - Click and drag one of the control handles to make it smaller
- Left-click the now-exposed bottom control (
Text0
) - Make whatever changes to the bottom control you need to
- Left-click the resized top control (
Text0
) - Click and drag one of the control handles to restore its size
Like the previous option, we need to remember to revert a change that we've made to our form design. That's such an easy thing to forget to do, I really don't like this option much better than Option 2. It's usually more obvious when you forget to revert a change made to the size of the top control rather than to its z-order. However, it's not always easy to resize the top control to the exact same size and position it had originally.
Don't worry, there's a better way.
Option 4: Deselect the Top Control
This is my go-to approach, and I don't think it's widely used.
- Click and drag from an empty area of the form over the stacked controls (this results in a "Multiple Selection" as seen in the first screenshot above)
- Hold down the [Shift] key and left-click the multiple selection
This deselects the top control in the z-order leaving only the bottom control still selected.
(NOTE: [Shift]-clicking controls toggles inclusion of the clicked control in the selection group.)
Form/Report Selection Behavior
In the screenshot above, notice that I have not fully enclosed the controls I'm trying to select. This is the default behavior, but it is a configurable setting.
- Go to File > Options > Object Designers
- Scroll down to Selection behavior under the "Form/Report design view" heading
You can switch this setting to "Fully enclosed" if you are so inclined. With the "Fully enclosed" option, you will need to draw your selection rectangle completely around the outside of the controls you want to select.
Reader Feedback
Did I leave any options out? Let me know in the comments below if you have a different trick you like to use to select the bottom control in a group of stacked controls.