Master detail Lookup Components

Introduction

The standard Delphi DBlookup objects cannot be linked to a TTable that has a MasterSource 
assigned to it. This is a serious limitation when designing master-detail relations that 
require the use of a Combobox. 
Several solutions are available (i.e. PowerObjects of Woll2Woll), but have performance 
limitations. Moreover they require additional coding. I have developed a component that 
uses the standard TTable/TDatasource objects. I named them TmdDBLookupCombo and 
TmdDBLookupList (md stands for Master-Detail). They are both modifications of the standard 
TDBLookupCombo and TDBLookupList components and are used the same manner.

Procedure

1. Create a lookup TTable object and link it to a database and select a TableName. Also create a 
tDataSource and connect it.
2. Link the TTable to a MasterSource, select the MasterField and join it to the master table. An index is 
automatically selected corresponding to the joined field.
3. Create an mdDBLookupCombo object and link the DataSource/DataField to a Master field of a Master 
TTable object.
4. Connect the LookupSource to the lookup TDataSource object. Only not yet connected DataSources 
are listed. If only one DataSource is available at creation time, the LookupSource property is 
automatically initiated with this Datasource.
5. Select the LookupField from the list. Only relevant detail indexes are shown ! (Here is where this object 
differs from the standard Delphi component: this shows only the MasterKey).
6. The IndexFieldNames property of the LookupSource-TTable is automatically adjusted to the selected 
LookupField-MasterKey combination.
7. Select a LookupDisplay field.

That's all there is. The Listbox is used the same way.


My address is:
Herman Steigstra
De Haaghe 13
NL-6641 JA Beuningen
The Netherlands
(CompuServe 100637,1276)


Herman Steigstra