1

I have created a form with 2 tab pages that take 2 different datasources, the problem is that the 2 tables used as datasources do not have a relation and I created a query in the init method of the form which links the 2 tables.

When I open the form, the result does not show for one vendor in tab1 to show all customers for this vendor on tab2.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
AXING
  • 41
  • 1
  • 6

1 Answers1

0

Almost newer create a datasource query from scratch, update the query instead.

You will have to join the datasources, based on your description, it should be with LinkTypeDelayed.

Second you have to have a dynalink between the datasources, defined in the init method of the second datasource.

public void init()
{
    super();
    this.queryBuildDataSource().addDynalink(fieldNum(VendTable,Party), CustTable, fieldNum(CustTable,Party));
}

There are other ways to accomplish this, but this one is the best most often.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Yes, tried even with executeQuery but wanted to do it in the init method,it worked this way,thank you.Whati if I want to add ranges from both tables ,I should add them here,in this method or elsewhere? – AXING Sep 30 '15 at 13:06
  • 2
    Static ranges goes to the `init` of the corresponding datasource. Dynamic ranges must be setup before the call to `super()` in `executeQuery` or before the call to `executeQuery`. – Jan B. Kjeldsen Sep 30 '15 at 13:08
  • I want to use the form as a lookup form, so the ranges should be dynamic depending on the record i pass with args to the lookup form... – AXING Sep 30 '15 at 13:11
  • This counts as static in this context. Be sure to look at other lookup forms to get the right look-and-feel and behavior. – Jan B. Kjeldsen Sep 30 '15 at 13:12
  • Already done before the call of the executeQuery but it is not working.Any suggestion of lookup form to look at? – AXING Sep 30 '15 at 13:16
  • `init` would be better. There are a lot, `CustTableLookup`, `ProjTableLookup` etc. – Jan B. Kjeldsen Sep 30 '15 at 13:18
  • Also, in lookup forms, do a `clearDanylinks` before `addDynalink` or call to `super`. – Jan B. Kjeldsen Sep 30 '15 at 13:32
  • i can do the filter separately in the respective init of the datasources but i dont want to show the parent record if it does not have linked child records...how can i do this? – AXING Sep 30 '15 at 13:47
  • Use a third datasource, same table and filtering as the second, join to the first with `existjoin`. – Jan B. Kjeldsen Sep 30 '15 at 16:17
  • Sorry, you mean i can filter the parent and the child in the respective init of the datasources and then what should i do with the third datasource..? – AXING Oct 01 '15 at 07:16
  • The third is to do an `ExistsJoin` to filter the first datasource which has records in the second. The join should be established using `addLink` rather than `addDanylink`. See also http://stackoverflow.com/a/12258102/4509 – Jan B. Kjeldsen Oct 01 '15 at 11:00