Hi, with us here, there are two approches. (Warning: we're "procedural" guys!)
1- If new lines are to be added and the input has to be checked (range, duplicates etc.) before storing in the db, there is the method to switch off automatic saveing in the table control and do your own thing. Be warned, when switching that checkbox off, you will not be able to reach an empty new line without the code lines shown later ...
[attachment 2776 Table1.png]
Then, there is a lot of code (in one of the most simple windows I found for you) ...
First the entry into a row - you have to take care whether you're entering an empty row (=> Creation) or a row showing an existing record (=> Modif) [attachment 2777 Table2.png]
Next, we let the user do whatever s/he wants, we are just waiting for him/her to leave the row .... now the great check of all of the values of the row will start ...
IF RowMode = "Modif" THEN // Validity IF Table.BGR_NUM < 1 OR Table.BGR_NUM > 999 THEN Error("Die Backzettel-Gruppen-Nummer muß im Bereich von 1 bis 999 liegen !") Table.BGR_NUM = OLD_BGR_NUM ReturnToCapture(Table.BGR_NUM) END IF NoSpace(Table.BGR_BEZ) = "" THEN Error("Es muß eine Bezeichnung der Backzettel-Gruppe eingetragen werden !") Table.BGR_BEZ = OLD_BGR_BEZ ReturnToCapture(Table.BGR_BEZ) END IF OLD_BGR_NUM <> Table.BGR_NUM THEN // check for dups MyPosition = HSavePosition(BACKZETTELGRUPPE) HReadSeekFirst(BACKZETTELGRUPPE,BGR_NUM,Table.BGR_NUM) IF HFound(BACKZETTELGRUPPE) AND Table.BGR_NUM = BACKZETTELGRUPPE.BGR_NUM THEN Error("ÄNDERUNG: Die Backzettel-Gruppe "+BACKZETTELGRUPPE.BGR_NUMBEZ+" war schon vergeben !") Table.BGR_NUM = OLD_BGR_NUM IF MyPosition > 0 THEN HRestorePosition(MyPosition) ReturnToCapture(Table.BGR_NUM) END IF MyPosition > 0 THEN HRestorePosition(MyPosition) ELSE // Re-Positionieren HReadSeekFirst(BACKZETTELGRUPPE,BGR_NUM,Table.BGR_NUM) END BACKZETTELGRUPPE.BGR_NUM = Table.BGR_NUM BACKZETTELGRUPPE.BGR_BEZ = Table.BGR_BEZ HModify(BACKZETTELGRUPPE) TableDisplay(Table,taCurrentSelection) ELSE // RowMode = "Creation" IF not KeyPressed(kpEscape) THEN IF Table.BGR_NUM <> 0 OR NoSpace(Table.BGR_BEZ) <> "" THEN IF KeyPressed(kpEscape) THEN // ESC-taste Table.BGR_NUM = 0 Table.BGR_BEZ = "" TableSelectMinus(Table) ReturnToCapture(GoToTable) END IF Table.BGR_NUM < 1 OR Table.BGR_NUM > 999 THEN Error("Die Backzettel-Gruppen-Nummer muß im Bereich von 1 bis 999 liegen !") Table.BGR_NUM = 0 ReturnToCapture(Table.BGR_NUM) END IF NoSpace(Table.BGR_BEZ) = "" THEN Error("Es muße eine Bezeichnung der Backzettel-Gruppe eingetragen werden !") Table.BGR_BEZ = "" ReturnToCapture(Table.BGR_BEZ) END MyPosition = HSavePosition(BACKZETTELGRUPPE) HReadSeekFirst(BACKZETTELGRUPPE,BGR_NUM,Table.BGR_NUM) IF HFound(BACKZETTELGRUPPE) AND Table.BGR_NUM = BACKZETTELGRUPPE.BGR_NUM THEN Error("NEU-EINGABE: Die Backzettel-Gruppe "+BACKZETTELGRUPPE.BGR_NUMBEZ+" war schon angelegt !") Table.BGR_NUM = 0 IF MyPosition > 0 THEN HRestorePosition(MyPosition) ReturnToCapture(Table.BGR_NUM) ELSE IF MyPosition > 0 THEN HRestorePosition(MyPosition) BACKZETTELGRUPPE.BGR_NUM = Table.BGR_NUM BACKZETTELGRUPPE.BGR_BEZ = Table.BGR_BEZ HAdd(BACKZETTELGRUPPE) TableDisplay(Table,taInit) TableSelectPlus(Table,TableCount(Table)+1) ReturnToCapture(Table.BGR_NUM) END END ELSE // ESC gedrückt! Table.BGR_NUM = 0 Table.BGR_BEZ = "" TableSelectMinus(Table) ReturnToCapture(GoToTable) END END The window look like that:
[attachment 2778 Table3.png]
The code behind the button [ <= Tabelle ] looks like that
IF Table..State = Active THEN Table = TableCount(Table)+1 ReturnToCapture(Table.BGR_NUM) END 2. - The second method is the much simpler one. We specify that no new data records may be entered. Modification of existing records, no new ones. The sensitive parts are being hid (= made read-only) from the end-user, some other fields of the record can be input. Since R/O colums are different in color (here, it is a painful pink) end users can easily see those fields which can be modified. |