こんにちは。
Delphi5、Windows2000の環境で開発をしています。
QuickReportでDBに繋げずに帳票を出力したいのですが
理想通りにいかず困っています。
DBに繋げずに出力するためにOnNeedDataを使用しています。
そこでキーが変わったときに改ページを行いたいのです。
改ページは上手くいくのですが
改ページ後のDetail1行目(2ページ目の1行目)に
前ページの最後の行のデータが出力されてしまいます。
OnNeedData部分のソースです。
FileNameが変わったら改ページをしたいのです。
-------------------------------------------------------------
DataCNT:データ件数カウント
Arr_PrintData:出力するデータ配列
if (DataCNT <= High(Arr_PrintData)) then begin
if (FileName = Arr_PrintData[DataCNT, 0]) then begin
QRL_Data1.Caption := Arr_PrintData[DataCNT, 1];
QRL_Data2.Caption := Arr_PrintData[DataCNT, 3];
QRL_Data3.Caption := Arr_PrintData[DataCNT, 4];
QRL_Data4.Caption := Arr_PrintData[DataCNT, 5];
QRL_Data5.Caption := Arr_PrintData[DataCNT, 6];
Inc(DataCNT);
end else begin
QuickRep1.NewColumn;
FileName := Arr_PrintData[DataCNT, 0];
end;
MoreData := True;
end else begin
MoreData := False;
end;
----------------------------------------------------------------
何が原因なのでしょうか?
アドバイスをお願いします。
データがきちんとNextされていますでしょうか?
外しているかもしれませんがQRSubDetailを使用してはいかがでしょう?
イベントにOnNeedDataがあるのでそちらだと判定もしやすいかと思います。
これで上手く動くと思います。
NewColumnの後もNeedDataのイベントは継続しますので。
if (DataCNT <= High(Arr_PrintData)) then begin
if (FileName <> Arr_PrintData[DataCNT, 0]) then begin
begin
QuickRep1.NewColumn;
FileName := Arr_PrintData[DataCNT, 0];
end;
QRL_Data1.Caption := Arr_PrintData[DataCNT, 1];
QRL_Data2.Caption := Arr_PrintData[DataCNT, 3];
QRL_Data3.Caption := Arr_PrintData[DataCNT, 4];
QRL_Data4.Caption := Arr_PrintData[DataCNT, 5];
QRL_Data5.Caption := Arr_PrintData[DataCNT, 6];
Inc(DataCNT);
MoreData := True;
end else begin
MoreData := False;
end;
通りすがりさん、えびさん
アドバイスありがとうございます。
えびさんのソース通りに直したら
理想通りに出力できるようになりました。
NewColumnしただけではダメだったのですね。
また何かありましたらよろしくお願い致します。
ありがとうございました。
ツイート | ![]() |