DOCUMENT #770
===========================================================================
MULTIPLE REGIONS ON A FORM
===========================================================================
PRODUCT: R:BASE VERSION: 4.5+ or Higher
===========================================================================
CATALOG: Forms, Reports & Labels AREA : Forms
===========================================================================
It is often difficult to set up a form with multiple regions to make data
entry easy. Generally the desired form set up to enter a row into table 1,
enter a row into table 2, enter multiple rows into table 3, enter another
row into table 2 and then more rows into table 3. This data entry sequence
was difficult in versions of R:BASE prior to 4.5 Plus!. You didn't have the
capability to move backwards a table in a form (the new Shift-F7 or
Previous table). You could circle around and often lost the linking column
information.
You can just use the Shift-F8 and Shift-F7 keys, but instead of having your
users press keys to move between regions, the movement is transparent using
EEPs. This article shows two different ways to enter data in this sequence.
One technique uses a form-in-a-form to enter data into the second region
(table 3); the other uses the new EEP commands NEXTTAB and PREVTAB to move
between the regions. The regions operate more like single table forms in
that pressing [Enter] on the last field in a row takes you to the next
table. Users don't need to remember particular keystrokes. Also, these
techniques leave the user on the next row in region 1 (table 2) ready to
enter data, not on the same row as when using Shift-F7 and Shift-F8.
Using a form-in-a-form
Using a form-in-a-form to move between regions makes use of what is called
a "windowed" form. The second region is a second form that has no text,
just located fields. It is displayed on top of the other form at the same
location where you would normally have placed the second region.
You need to make two forms for this procedure: a two table form and a one
table form. The first form or calling form is the two table form. It has
the first table, the one that isn't a region, and the second table, the
first region. Design it to leave room for the display of the second form
and region. The second form is designed using some special techniques so
it can be displayed on top of the other form.
The EEP is really very simple. Most of the work is done by the forms. We
trap for the [Esc] key or the [Alt] keys; we don't want to execute the
second form when the user goes to the menu. The EEP is placed as a table
level EEP on table 2, the first region. Place it After saving a row.
*(REGION2.EEP)
SET VAR vkey = (LASTKEY(0))
IF vkey = '[Esc]' THEN
RETURN
ENDIF
ENTER region2 AT 17
SCREEN RESTORE OFF
When you use the form, pressing [Enter] on the last field of a row in
region1 will save the row and then execute the EEP. The second form will
be displayed, to the user it looks like a single form. Use Esc to leave the
second form. Esc will automatically return you to the second table/region 1.
You can add an EEP to the second form to trap for various keystrokes, but
it's not necessary.
Form expressions are needed to transfer the linking column data between the
two forms. In form1 add an expression, vlink = linkcol, add the expression
linkcol = .vlink to form2.
Using NEXTTAB and PREVTAB
Again we need to trap in the EEPs for the keys that take a user to the
menu. We don't want to execute the rest of the EEP code in those situations.
These are table level EEPs. The EEPs are placed After saving a row. Because
you are staying in a single form no expressions are needed to transfer
values between forms. The first EEP is placed on the first region After
saving a row.
*(NEXTTAB.EEP)
SET VAR vkey = (LASTKEY(0))
IF vkey <> '[Esc]' THEN
NEXTTAB
ENDIF
The second EEP is placed on the second region, After saving a row. After
each row is entered in the second region, the EEP asks if the user wants
to add another row. This is easier than trapping keystrokes.
*(PREVTAB.EEP)
SET V vkey = (LASTKEY(0))
SWITCH (.vkey)
CASE '[Esc]'
CASE '[Alt]%'
RETURN
BREAK
CASE '[enter]'
DIALOG 'Add another row?' vresp vendkey YES
IF vresp = 'yes' THEN
RETURN
ELSE
PREVTAB
ENDIF
BREAK
CASE DEFAULT
BREAK
ENDSW
RETURN
Using these EEPs, users move transparently between two regions on a form
making for easy data entry.