6

The LA Fox Developer Newsletter
May 1998
An easy way to...
Add Field-Level Help to
Your Data Entry Forms
Use this generic help panel to guide your users through your
data-entry forms.

There are five obvious ways of providing help for data-entry
operators in Visual FoxPro:
1. Write a help topic for the data-entry form; invoke it with the
HELP and/or SET TOPIC commands.
2. Associate a help topic with the field’s HelpContextlD
property; the topic will be displayed when the user hits Fl.
3.
Use the WhatsThisHelp system; this lets the user select
the Help icon in the form’s title bar, then point and click on a
field to get help (in VFP 5.0 and above only).
4.
Display the help text as a tooltip.
5.
Display the help text on the status bar, using either SET
MESSAGE TO or the StatusBarText property.

The first three are fine if the user only needs occasional help.
But, because they require specific action on the user’s part,
they are less suitable for people who need constant guidance
on every field.

Tooltips are usually a good option, but they offer only limited
space for the help messages, they are distracting to experi-
enced operators (you need to provith a way to turn them off),
and they are of no help to non-mouse users.

As for status bar text, users don’t always like having to shift
their gaze from the form to the foot of the screen. Besides, the
FoxPro status bar has an old-fashioned feet. Many developers
switch it off to avoid users having to see record numbers,
locking messages and the like.

Another Ootion

We’d like to tell you about another option for field-level help
one which we have used successfully in several applications. It
is completely generic and requires only a few of tines of code to
implement. Our users like it because it is non-intrusive and
does not demand any action on their part. Best of all, it does
not require you to write help topics or keep track of context lDs.

To the user, the help text appears on a small panel at the foot of
the data-entry form (see Figure 1). The text is displayed auto-
matically as the user moves focus from field to field. We use a
gentle color combination for the text blue on gray is a favorite
choice as this makes it easy for users to ignore the mes-
sage if they don’t need to see it.

What’s interesting about this technique is that the help text is
not stored in the application. Nor is it in a help file. It is held in
the field’s Comment property within the database. The advan-
tage of this is that the text can be maintained centrally. You
only need one instance of the help message per field, and, if
you need to change it, you only have to do so in one place.


Figure 1: A help message for the field in focus appears in a
small panel at the foot of the form.


Imølementation

To implement the technique, first add the help panel to your
base data-entry form. The panet is simply a label with a different
background color from the rest of the form. We generally set its
BorderStyle property to Fixed Single and its WordWrap property
to.T.

Next, add a custom method to the base form. Call it, say,
ShowHelp. The method simply displays, in the label, whatever
text is passed to it as a parameter, like this:

LPARAMETER cTextToShow
THIS.HelpPanel.Caption = clextToShow

(“HeipPanel” is the name of the label in this example.)

The next step is to arrange for each field in the form to call the
method and to pass it a parameter as it receives focus. The
obvious place to do that is in the GotFocus event of the data-
entry field’s base class. The code might look like this:

THISFORM.ShowHelp(DBGETPROP(THIS.ControlSource,”FieId”,”Commenr’))

For this to work, the field’s ControlSource must point to a field in
a database table. The database field’s Comment property
should contain the help text; you enter this through the Table
Designer. If you omit the text for a given field, no harm wilt be
done the help panel will simply remain blank.

In case you are wondering, DBGETPROPO is a built-in VFP
function which, among other things, allows you to access any of
the field or table properties for any database table. You could
use itto get at the validation rules, the validation error mes-
sages, the format and input masks, and quite a lot more. See
the VFP help file if you’d like to know more.
(Con’t, page 8)
Page 6

6