Automating Inner Join using LookupComboBox component

3

Sometimes I use the TDBLookupCombobox component to bring up a list of 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 another a list of clients, however the clients should appear according to the chosen store, so is there a data ware type component that automates this?

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

    
asked by anonymous 21.02.2015 / 08:29

1 answer

1

What you can do is the following, following your example, bring in the query all the clients and all the stores, each one of them in its dataset . Set both lookup's accordingly, now to make the effect you want without going again to make a query in the database set the event AfterScroll on dataset of the client to look like this:

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

In this way, each roll in the dataset of the client will be filtered dataset of the store. remembering that in the dataset of the store it is necessary to enable the filtered := True property.

    
21.02.2015 / 11:33