unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, StdCtrls, DBCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
MasterQuery: TQuery;
MasterDataSource: TDataSource;
MasterDBLookupListBox: TDBLookupListBox;
DetailQuery: TQuery;
DetailDataSource: TDataSource;
DetailDBLookupListBox: TDBLookupListBox;
procedure Button1Click(Sender: TObject);
procedure MasterDBLookupListBoxClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
// MasterQuery
MasterQuery.Active := false;
MasterQuery.DatabaseName := '
FAM001_Lvs';
MasterQuery.SQL.Clear;
MasterQuery.SQL.Add('
select distinct dnote_id from disp_head');
MasterQuery.Prepare;
MasterQuery.Active := true;
// MasterDataSource
MasterDataSource.DataSet := MasterQuery;
// MasterDBLookupListBox
MasterDBLookupListBox.ListSource := MasterDataSource;
MasterDBLookupListBox.KeyField := '
dnote_id';
// DetailQuery
DetailQuery.Active := false;
DetailQuery.DatabaseName := '
FAM001_Lvs';
DetailQuery.SQL.Clear;
DetailQuery.SQL.Add('
select distinct art_id from disp_line');
DetailQuery.SQL.Add('
where dnote_id = :dnote_id');
DetailQuery.ParamByName('
dnote_id').AsInteger;
DetailQuery.Prepare;
DetailQuery.DataSource := MasterDataSource;
DetailQuery.Active := true;
// DetailDataSource
DetailDataSource.DataSet := DetailQuery;
// DetailDBLookupListBox
DetailDBLookupListBox.ListSource := DetailDataSource;
DetailDBLookupListBox.KeyField := '
art_id';
end;
procedure TForm1.MasterDBLookupListBoxClick(Sender: TObject);
begin
// DetailQuery neuaufbauen
DetailQuery.Active := false;
DetailQuery.Active := true;
end;
end.