Master-detail with two DBLookupComboBoxes lazarus / 16-Databases ---------------------------------------------------------------------- percentage · 2013-12-21 15:27 Lazarus 1.0.14, Zeos 7.1.2, VirtualDBGrid, Firebird. I have three tables. Two list tables, Car and Model, each have FKs in a Garage table. Between the Car and Model tables there is a M-D relationship (TZQueries). On a form I have two DBLookupComboBoxes with ListSources connected each to Car and Model, and both DataSources to Garage, to update the FKs. What I want: when I select a Car in the first DBLookupComboBox, the second one should display only the Models of the selected car. I tried among other things to set the ScrollListDataset of the master DBLookupComboBox to True, but it doesn't work. The dbl-combo that should display the model only shows the models for the first primary key from the Car table. If I connect two grids to Car and Model, I see the M-D working like it should. How do you do it with DBLookupComboBoxes? ---------------------------------------------------------------------- CaptBill · 2013-12-21 16:33 You should simply need to catch the onchange event of the master table "cars" then query or filter the detail table "models". ---------------------------------------------------------------------- percentage · 2013-12-22 13:30 Thanks, I tried your suggestion and it worked. I removed the M-D relationship between the queries and I put this in the OnChange event of the DBLookupComboCar: with QueryModel do begin   Filter:='IDCAR = ' + QuotedStr(DBLookupComboCar.KeyValue);   Close;   Open; // Refresh doesn't work. end In my opinion, it should have worked out of the box after setting the M-D relationship, no filtering required, like grids. But now there is the question of efficiency. Which one is better? M-D between queries, or setting up a filter?