0
votes

I have a DBLookUpComboBox and DBGrid connected to the same table with two different data source components. Im trying to narrow the DBGrid results by filtering that datasource with the selected key value from the DBLookUpComboBox. It does filter the grid however when I select a key value it edits the first row with the selected key value in the grid. why is this happening?

procedure TForm1.DBCBtypeClick(Sender: TObject);
 begin
  showmessage('Book Type: ' + dbcbtype.KeyValue);

  dmpub.tbooks.Filter := 'type = ' + quotedstr(dbcbtype.KeyValue);
  dmpub.tbooks.Filtered := true;

end;

Everything else is in the properties of the components

1
Don't set the Datasource of the DBLookupComboBox, just set the ListSource.. - John Easley
Yup that did it. John your good - user3777681

1 Answers

3
votes

Setting the Datasource property of the TDbLookupComboBox will place the dataset in dsEdit state. If you just want to use the TDbLookupCombo box for selecting a value from the lookup, just leave the Datasource property blank. The control will still provide a list by using the ListSource, ListField and ListFieldIndex properties.