how do i solve this

Hi I have a form which has a main and sub form. the table related to the subform does not have values, in the sense when i open this form the values to the subform are populated from another table. I will try to be more clear with an eg. table1, table2,table3. forms - form1 is based on table1 and form1 also has a subform- which is related to table2. and as i said above table2 doesnot contain any values. so when i open form1 i want the values(some) to be inserted into table2 from table 3 and shown simulataneously on form1 more specifically on the subform present in the form1. this should be true to all the records present in the main table i.e table1… how do i go abo Edited by - MVGS on 2002 Jan 15 10:00:41

Don’t think too far. Your problem has nothing to do with the forms. The only problem to solve is: populate tabel2 based on records of table3 (where table1 might provide some keys for table3). We need two easy steps: Step 1 is to invoke the initialization process. Let’s assume we have a procedure InitTable2 (PKField1, PKField2 : Code10) This procedure could e.g. be invoked by the main form by pressing a button. Step 2 is to create the procedure InitTable2 which I would put witihn the c-side code of Table2. The procedure could look like this:

Procedure InitTable2 (PKField1, PKField2 : Code10;

BEGIN
  table3.setcurrentkey (field1, field2);
  table3.setrange (field1, PKField1);
  table3.setrange (field2, PKField2);
  if table3.find('-') then Repeat
    if not table2.get ( ...) then begin
      table2.PKField1 := ....
      table2.PKField2 := ....
      table2.insert(true);
    end;
    table2.field3 := ...
    table3.field4 := ...
    ...
    table3.fieldn := ...
    table3.modify (true);
  Until table3.next <= 0;
END;

Having invoked this procedure from within form1 you don’t have to care about displaying the table2-records in subform2. You might howerver invoke a

CurrForm.Update

in form1 to have the results displaied: form1.Button.OnPush;


InitTable2 (field1, field2);
CurrForm.Update;

Hope this helps. With best regards from Switzerland Marcus Fabian

Hi Marcus i have just gone through your answer, but i do not have any button to do as you said, subform should be updated as soon as i open the form and as i trace through the other records of the main form. Hope you understood my problem. thanx Kumar

Hi, If you don’t have a button then try Ontimer()trigger. Remember you will not be able to insert on OnAfterGetCurrRecord() / OnAfterGetRecord() Satbir