Solved

I don't get the Qreport OnNeedData...

Posted on 2000-02-19
9
571 Views
Last Modified: 2012-05-04
Hi, I have a TStringList which I want to print in a report. One subdetailline per String in the List.
So, I figured I have to use the OnNeedData event of the subdetail to print each rule.
No I have the following code:

procedure TLCRepForm.HygOpdtNeedData(Sender: TObject;
  var MoreData: Boolean);
begin
  if HygList.Count > ListCount then
begin
  HygOp.Caption := GebouwList.Strings[ListCount];
  Inc(ListCount);
  MoreData := GebouwList.Count > ListCount ;
end;
end;

where the HygOp is a label on my subdetailrecord. I have the dataset of the subdetail empty..
I can't figure out what I'm doing wrong.. It just print nothing...

Thanks,

Lizzzard
0
Comment
Question by:lizzzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 2538139
lizzard,

have you set the ListCount to zero?
Why do you use a subdetail and not a detail? If you use a subdetail, then how is it related to the detail?

here is code that works (with ListView and Detailband):

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, QuickRpt, Qrctrls;

  type
   TfrmNeedData = class(TForm)
     QuickRep1: TQuickRep;
     QRLabel1: TQRLabel;
     TitleBand1: TQRBand;
     DetailBand1: TQRBand;
     procedure FormCreate(Sender: TObject);
     procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
        var PrintReport: Boolean);
     procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
     private
      { Private declarations }
      SomeList: TStringlist;
      CurrentIndex: integer;
     public
      { Public declarations }
     end;

   var
    frmNeedData: TfrmNeedData;

   implementation

uses Unit1;

                      {$R *.DFM}

 procedure TfrmNeedData.FormCreate(Sender: TObject);
   var
    i: integer;
 begin
 end;

 procedure TfrmNeedData.QuickRep1BeforePrint(Sender: TCustomQuickRep;
   var PrintReport: Boolean);
 begin
   // You must reset your data in the BeforePrint event
   // or when you print from the preview, the report will
   // start with the last value(s)
   CurrentIndex := 0;
 end;

 procedure TfrmNeedData.QuickRep1NeedData(Sender: TObject;
   var MoreData: Boolean);
 begin
   // If MoreData is true, then QuickReport will print
   // another detail band.  When you set it to false,
   // the report is done.

   MoreData := (CurrentIndex <    form1.ListView1.Items.Count);

   if MoreData then
   begin
    QRLabel1.Caption := form1.ListView1.Items[CurrentIndex].caption;
    // Here's how to set the progress bar
    QuickRep1.QRPrinter.Progress := (Longint(CurrentIndex) * 100) div form1.ListView1.ITems.Count;
   end
   else
    QuickRep1.QRPrinter.Progress := 100;
   Inc(CurrentIndex);
  end;

end.

Zif.

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2538153
just replace the listview with your stringlist and it should work fine.

Zif.
0
 

Author Comment

by:lizzzard
ID: 2538164
Hi, ZiF!!!!

Long time no see! How's it hanging?

Thanks for you comment..
I use a subdetail because it is a subdetail...
I want to report from a master/detail recorset, in which one of the  fields of the detail is a DBMemo.
I want to add some comment text to each line of the memo (which I have assigned to a TStringList for my convience)...
And yes.. I have set ListCount to 0... Nice try though..

I will try your code in my report.

Regards and all the best from Holland,

Lizzzard
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 8

Expert Comment

by:ZifNab
ID: 2538388
Hi lizzzard,

all things fine here (and in Belgium too :-) ).Mmmm, can you test somehow if the subdetail band is used during report time?

Zif.
0
 

Author Comment

by:lizzzard
ID: 2538568
Zif,

I tried your solution, and it worked But I don't get what I'm doing wrong in my code..
Now I have another problem.. See my new question.. hehehe

Regards,

Lizzard...
0
 

Author Comment

by:lizzzard
ID: 2538569
PS

do you want the points for your comment???
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 2538642
great that it works. :-)

I don't get notifications when comments are given :-( that's why I'm so slow in reaction to your messages. Sorry !

you can publish your code and maybe I can find the problem which you're overlooking?

Zif.
0
 

Author Comment

by:lizzzard
ID: 2538727
It's OK with your code, Zif..  I have to finish this project soon,  So if it works, it works. I'm not normally like that.. Right now I have hellhounds on my trail..

Thanks anyway.
0
 

Author Comment

by:lizzzard
ID: 2545232
Sorry Zif...

I saw I forgot to grade you...
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question