Highlight the Current Field in Data-Entry Forms
Problem
The text cursor is too small in Access, and you can’t always tell which text box on a form has the focus. You need some way to really highlight the current field.
Solution
There are many visual cues you can use to tell the user which text box contains the cursor. You can change the color of the text or the background, change the appearance of the text box, or change the appearance of the text box’s label.
The simplest solution, which works quite well, is to change the BackColor and SpecialEffect properties of the active control. This solution uses some simple VBA code, which is attached to each control’s Enter and Exit events, to do the work. Figure 2-3 shows the sample form, frmEffects, in use (with the City field currently selected).
Figure 2-3. frmEffects in use, showing the active field
Open 02-02.MDB
and load frmEffects. As you move
from field to field on the form, note that the special effect and the
background color of each control change when you enter and again when
you leave the control.
Follow these steps to create a form with this same sort of functionality:
Create a new module and name it basSpecialEffects. In the declaration section, create the following constants, which will represent the controls’ SpecialEffect and BackColor property settings:
Option Compare Database Option Explicit Private Const conWhite = ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.