delphidelphi-xe2tclientdatasetdata-awaretcombobox

LookupSource must be connected to TTable component


I'm attempting to use a TDBLookupCombo, but am getting an error "EInvalidOperation with message 'LookupSource must be connected to TTable component'.

I have the TDBLookupCombo.LookupSource connected to a TDataSource. The TDataSource.Dataset is pointing to a TClientDataSet which contains the records for the lookup table (Fields ID and Description).

LookupDisplay := 'Description';
LookupField := 'ID';
LookupSource := dsLookup;

Is this not possible to do since TCilentDataSet isn't a descendant of TTable? If so then what would be the best alternative without using 3rd party components.


Solution

  • TDBLookupCombo is one of the old BDE-based data controls, which is why it's dependent on connecting to a TTable.

    It seems you should be using TDBLookupComboBox instead, which works fine connected to a TDataSource which is attached to any bi-directional TDataSet descendant (which includes TClientDataSet).