Managing Margins Of Text Box and Label Controls

This month, Chris Weber talks about four TextBox and label formatting properties that were introduced in Access 2000–and some unexpected side effects of using them.

In Access 2000, the Access development team at Microsoft introduced four new formatting properties for TextBox and label controls. They appear on the Format tab of the property sheet as Left Margin, Top Margin, Right Margin, and Bottom Margin (see Figure 1). These margins are measured in inches and can be used to pad the “whitespace” around your data or caption within the control. This is especially useful for controls that are sunken, raised, or have a solid border. It’s a great idea that can make your form’s data more readable, and result in fewer data entry errors, decreased eyestrain, and greater productivity for your users. However, they can also have some nasty side effects.

 
Figure 1

In Figure 2, I’ve added my favorite 0.05″ Left Margin to the controls for a sample Employees form. Clearly, the version with the margin padding is easier to read. But you can also see those side effects I mentioned earlier. For instance, the memo control whose Left Margin has been set has lost its scrollbars. The first time I noticed this, it took me 45 minutes to figure out that the Margin property was the culprit that was preventing my users from seeing the rest of the memo. It’s a shame that the one place where readability is critical–memo fields with large amounts of text–can cause large portions of a memo not to be readable at all. The only solution seemed to be to avoid using margins for any TextBox controls where a scrollbar may be required.


Figure 2

Phantom margins

Then, a few weeks ago, one of my clients asked that a Zip code TextBox be changed to a ComboBox of Zip codes from which their users could choose valid values from a new lookup table. “Easy enough,” I thought, “I’ll just convert the original control to a ComboBox using the Format | Change To menu option in form design view, and then set the data properties.”

Suddenly, my ComboBox had a grey dead space around it (see Figure 3). This time it only took me 15 minutes to figure out that the problem was margin-related. My original TextBox had a Right Margin setting and the grey area was a remnant of the control’s previous TextBox-related settings (luckily, this dead area only appeared in design view and disappeared when I ran my form).


Figure 3

Since a ComboBox doesn’t have Margin properties, I changed my control back to a TextBox, set the Right Margin to 0, changed the TextBox back to being a ComboBox, and reset all the data properties. However, I later discovered a simpler solution: Close and reopen the form to remove the design view phantom margin. Access apparently held the “leftover” Margin properties from the TextBox in memory rather than storing them in the form.

When mixed with other drugs

While I’ve found working with Margins problematic, I have warm feelings toward Conditional Formatting (also found under the Format menu in form design view). One of the ways that I use Conditional Formatting is to draw my user’s eye to the field with the focus by changing the background color of the control with the focus. My favorite background focus color is a pastel yellow. Clients love it, I get more work, all is good.

Note: In Access 2007/2010, Conditional Formatting is only found Layout view.

Well, it’s good until you mix Conditional Formatting with Margins. The result can create a truly ugly design, as shown in Figure 4. The Conditional Formatting background coverage interacts in strange ways with the Margin spacing. The interaction is affected by the way that the background color is set. For the Title field in the graphic, I’ve set the BackColor property to the same pastel yellow without using Conditional Formatting. In the Title field, the BackColor isn’t affected by the Left Margin setting.


Figure 4

The moral of this story? Be judicious in your use of Margins and remember that, while working out the bugs can be difficult for you, the readability benefits for your users far outweigh the costs.

 

This entry was posted in Old Material. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.