QuickReportのOnNeedDataについて

解決


makoron  2003-11-29 03:26:17  No: 5828

こんにちは。

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;
----------------------------------------------------------------

何が原因なのでしょうか?
アドバイスをお願いします。


通りすがり  2003-12-02 20:29:40  No: 5829

データがきちんとNextされていますでしょうか?

外しているかもしれませんがQRSubDetailを使用してはいかがでしょう?
イベントにOnNeedDataがあるのでそちらだと判定もしやすいかと思います。


えび  2003-12-02 21:21:18  No: 5830

これで上手く動くと思います。
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;


makoron  2003-12-02 23:21:10  No: 5831

通りすがりさん、えびさん
アドバイスありがとうございます。

えびさんのソース通りに直したら
理想通りに出力できるようになりました。
NewColumnしただけではダメだったのですね。

また何かありましたらよろしくお願い致します。
ありがとうございました。


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加