Page 1 of 1

Hierarchical Lookup Combos

Posted: 14.07.2008, 16:04
by Roaster
Hi,

I've got a master table:
PRODUCTS which contains two fields producttype and productsubtype
- A lookup table:
PRODUCTTYPE which contains the fields producttype and text
- A lookup table:
PRODUCTSUBTYPE which contains the fields productsubtype and text

I'm using a Zeos query and standard VCL components (including client
datasets) to access a Firebird database.

The following properties are set:
QueryProductType.DataSource := DatasourceProducts
ClientDataSetProductType.MasterSource := DatasourceProducts

QueryProductSubType.DataSource := DatasourceProductType
ClientDataSetProductSubType.MasterSource := DataSourceProductType
ClientDataSetProductSubType.MasterFields := producttype
ClientDataSetProductSubType.IndexFieldNames := producttype

I added two TDBLookupComboBoxes:
cbProductType.ListSource := DataSourceProductType
cbProductType.KeyField := producttype
cbProductType.ListField := text
cbProductType.DataSource := DataSourceProducts
cbProductType.DataField := producttype

cbProductSubType.ListSource := DataSourceProductSubType
cbProductSubType.KeyField := productsubtype
cbProductSubType.ListField := text
cbProductSubType.DataSource := DataSourceProducts
cbProductSubType.DataField := productsubtype

After opening the connection to the database I get some records of the
table PRODUCTS in a TDBGrid.

The cursor is placed on the very first record and both combos display the
correct text from the appropriate lookup table.

When moving the cursor to the next record, the combo box which holds the
product type changes accordingly but the sub type combo does not.

So what did I made wrong? Or is it impossible to have hierarchical
dependent lookup tables which themselves link to a single master?