2 tables in 1 form

Is it possible to design a form which has one source table and also place some components from another table (tables are related by key field)? What I did, I created global variable (record type, the 2nd table) and set source expressions like Var.Field. When I enter the data - it does not work, the 2nd table is empty…

You have to use some subforms on your main form and link them to your main table.

Hi, if you just want to include a couple of fields from a single record of a related table your idea with with a global var and var.field is fine - you just have to make sure that you update and “get” the var every time you change the record of the main source table: add the following code to the OnAfterGetRecord on the form: var.GET(Rec.KeyOfVar); Saludos Nils

Use Global Variables to show the data. On the OnAfterGetRecord set the global variables to the values on the second table. On the OnValidate trigger of the fields with the global variables update the second table. Paul Baxter

Yes, it’s possible… it’s really usefull in fact when having as example a company needing too much data in a table, so the record size limit is too small for putting all the different fields the customer wants in one table. In that case, usually you also populate the 2nd table when inserting a 1st table record, so you’ll have a 1->1 relationship between both tables (when inserting a record on the first table-> inserting a record on the 2nd). If you don’t want to populate that 2nd table on the onInsert event of the 1st table, you can do as follows also: You will need to create a couple of global variables record type 2nd table and set the source expresions on the controls to the first one (example: my2ndtablevar & my2ndtablevaraux). On the OnValidate event of the controls, do something like CLEAR (my2ndtablevaraux); my2ndtablevaraux.SETRANGE(keyfield1,keyfieldvalue1); my2ndtablevaraux.SETRANGE(keyfield2,keyfieldvalue2); … IF (my2ndtablevaraux.FIND(’-’)) THEN BEGIN my2ndtablevaraux.VALIDATE(FieldOnControl,my2ndtablevar.FieldOnControl); my2ndtablevaraux.MODIFY(TRUE); my2ndtablevar.GET(my2ndtablevaraux.keyfield1,my2ndtablevaraux.keyfield1,…); END ELSE BEGIN my2ndtablevaraux.INIT; my2ndtablevaraux.VALIDATE(Keyfield1, keyvalue1); my2ndtablevaraux.VALIDATE(Keyfield2, keyvalue2); … my2ndtablevarAux.INSERT(TRUE); my2ndtablevarAux.VALIDATE(FieldOnControl,my2ndtablevar.FieldOnControl); my2ndtablevaraux.MODIFY(TRUE); my2ndtablevar.GET(my2ndtablevaraux.keyfield1,my2ndtablevaraux.keyfield1,…); END; Remember that on the OnAfterGetCurrRecord you’ve to get if exists the my2ndtablevar record corresponding to that record and clear it when creating a new record. Regards, Alfonso Pertierra (Spain)apertierra@teleline.es

What if I want to display in a list which contains a header and lines ? I find that is difficult. For example, I would like to display ‘Description’ from Posted Service Header and ‘Description’ from Posted Service Item Line. Is this possible ? Well, let us not discuss about the logic behind this first. Thx in advance.

Problem is solved. In a table box, add a new text box with reference to a global variable. This example is assuming the form is referring to Posted Service Item Line and I wanted to add some fields from Posted Service Header. OnAfterGetRecord=BEGIN ServHeaderCustNo := ‘’; ServHeaderDesc := ‘’; ServHeader.GET(“Order No.”); ServHeaderCustNo := ServHeader.“Customer No.”; ServHeaderDesc := ServHeader.Description; END; Due to space constraint, you can email me to have the complete source code.