Hierarchical Lookup Combos

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Roaster
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 25.10.2007, 12:19

Hierarchical Lookup Combos

Post 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?
cu,
Michael
Post Reply