DOCUMENT #772
===========================================================================
NO MORE "NO EDITABLE DATA"
===========================================================================
PRODUCT: R:BASE VERSION: 4.5+ or Higher
===========================================================================
CATALOG: Forms, Reports & Labels AREA : Forms
===========================================================================
The RECALC TABLES can be used to get rid of "no editable data" messages
when editing data in multi-table forms. Lower tables may not yet have any
matching data records with table one in the form. When the user moves to
the lower table, they get a "No editable data in this table" message on
line 24. A new row can be added using the Add row option off the Edit menu
or the F10 key in 4.5 Plus! but this is not intuitive to users. Use an EEP
placed at the table level, On exit from a row, to automatically add a row
to the lower table if there is no matching data row already. Users will
never again see the "No editable data" message.
Using the Concomp sample database, modify the form custform. Add an
expression to table one of the form, Customer, to place the customer
identification number, custid, into a variable. The value needs to be
placed in a variable so the EEP can reference it. Define vcustid = custid.
The variable is not located.
The EEP uses SELECT to count the number of rows in the Contact table, table
two on the form, that match the current row in the Customer table. If no
matching rows are found, the EEP inserts a new row into the Contact table
and uses RECALC TABLES to ensure that the form displays that new row.
The EEP is placed On exit from a row. Because it executes anytime the user
leaves the row, you must check for keystrokes. If the user presses Esc or
moves to the menu using the Alt key you don't want to execute the commands
in the EEP.
*(nodata.eep
adds a row of data to lower tables in a form)
SET VAR vkey = (LASTKEY(0))
IF vkey = '[Esc]' OR +
vkey LIKE '[Alt]%' THEN
RETURN
ENDIF
SET VAR vcount INT = NULL
SEL COUNT(*) INTO vcount +
FROM contact WHERE custid = .vcustid
IF vcount = 0 THEN
INSERT INTO contact (custid) +
VALUES (.vcustid)
RECALC TABLES
ENDIF
RETURN
If you have more than two tables on your form, do a SELECT COUNT(*) and
an INSERT on each of the lower tables from this one EEP. The EEP executes
whenever you leave the row in table one -- including when you use the PgDn
key or the mouse to move to lower tables as well.
It is placed On exit from a row instead of After leaving section because
of when the EEPs execute. The EEP After leaving section also executes when
you leave the form, but not until you press Enter from the Exit menu
option. The EEP can't trap for this action -- it sees the keystroke [Enter]
not the keystroke [Esc]. It works well On exit from a row, however, just
remember to trap for certain keystrokes.