DOCUMENT #773
===========================================================================
LOCATE FIELDS OUTSIDE A REGION
===========================================================================
PRODUCT: R:BASE VERSION: 4.5+ or Higher
===========================================================================
CATALOG: Forms, Reports & Labels AREA : Forms
===========================================================================
An R:BASE form requires all fields for a table with a region defined to be
located inside the region boundaries. This often time necessitates making
a two table form instead of a one table form, or repeating data inside the
region. This procedure does not remove the rule, rather it circumvents it by
not locating fields, but using an EEP to look up the data and write it to
the screen instead of actually locating the fields. Of course this makes the
data non-editable, but is a quick and easy way to display additional data
anywhere on the screen.
The basic procedure is to place an EEP on Entry into the row for the region
table. A form expression, varname = colname, places the row identifier into
a variable so the EEP can look up the data. With SCREEN RESTORE OFF, the
EEP looks up the values into variables and writes them to the desired
position on the screen. This works when using the form to Edit data, the
variable values are looked up and displayed each row without the user
having to enter any data. When using the form to Add data you would need to
place the EEP on exit from the row identifier field. It would execute and
lookup the data values after the user enters data.
For example, create a single table form that is a region, use the salesbonus
table from the Concomp sample database. Define a form expression,
vempid = empid to place the column data needed for the lookup into a
variable. The EEP is placed on Entry into a row. The EEP uses the SELECT
command to look up matching data from the employee table into variables and
write it on the screen. As you move from row to row in the region the
lookup data is automatically refreshed.
Note that all the rows from the region table, salesbonus, are displayed,
not just matching rows as would be the case if you used a two-table form
with employee the first table and salesbonus the second table.
*(LOOKUP.EEP)
-- set the variables to NULL so they won't retain values
-- from a previous row
SET VAR vefname = NULL, velname = NULL, vphone = NULL
-- get the data to display
SELECT empfname, emplname, empphone INTO +
vefname ind1, velname ind2, vhiredate ind3 +
FROM employee WHERE empid=.vempid
CLS FROM 3 TO 6
SET VAR vname = (.vefname & .velname)
WRITE 'ID #: ', .vempid AT 3,12
WRITE 'Employee name: ' .vname AT 4,12
WRITE 'Phone #: ', .vphone AT 5,12
SCREEN RESTORE OFF
RETURN
This EEP does not return any data to the form, it is used for display only
.
Because it is executed on entry into a row you don't need to trap for any
keystrokes such as Esc; you always want it to execute. The data that is
looked and displayed on the screen can be from another table as in this
example, or from the same table the region is on.