mysql – Automating Inner Join using LookupComboBox component


Sometimes I use the TDBLookupCombobox component to bring up a list from a dataset lookup field, this approach streamlines some things but is quite limited.

For example I have a list of stores in one TDBLookupCombobox and in another a list of customers, but the customers must appear according to the chosen store, so is there a data ware component that automates this?

I do this in the traditional way using an inner join according to the chosen store and thus populating the second combobox, this one being of the TComboBox type.


What you can do is the following, following your example, bring in the query all the customers and all the stores, each one of them in your dataset . Configure both lookup's accordingly, now to make the effect you want without going again to query the database, configure the AfterScroll event in the client's dataset so that it looks like this:

procedure TMeuForm.MeuDatasetClienteAfterScroll(Dataset : TDataset);
  MeuDatasetLoja.Filter := Format('idcliente = %d', [MeuDatasetCliente.FieldByName('idcliente').AsInteger]);

that way every scroll the dataset customer will be filtered the dataset store. remembering that in the store's dataset is necessary to enable the property filtered := True .

Scroll to Top