首先設置AQmain datasource
AQDetail Datasource
AQDetaildatasource := Datasource
AQDetaillocktype := ltBatchOptimistic
procedure TFormFormCreate(Sender: TObject);
begin
if not AQMainactive then AQMainopen;
if not AQDetailActive then AQDetailOpen;
end;
procedure TFormButtonClick(Sender: TObject);
begin
AQMainPost;
end;
procedure TFormAQMainAfterPost(DataSet: TDataSet);
begin
AQDetailUpdateBatch();
AQDetailDataSource := DataSource ;
end;
procedure TFormButtonClick(Sender: TObject);
begin
AQMainAppend ;
AQMainFieldByName(Adate)value := datetostr(date());
end;
procedure TFormAQMainAfterInsert(DataSet: TDataSet);
begin
AQDetailDataSource := nil;
end;
procedure TFormAQDetailAfterInsert(DataSet: TDataSet);
begin
AQDetailFieldByName(mgrno)value:=AQMainFieldByName(mgrno)value;
end;
From:http://tw.wingwit.com/Article/program/Delphi/201311/24679.html