Qreport with List or Array

According to the help docs QReport is capable of using a list or a array as a datasource.
How can I accomplish this? - Examples please!
hoplaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ZifNabConnect With a Mentor Commented:
May I answer this one hopla? So it's removed from the 'To Do'-list. If not just reject this answer. Regards, Zif.
0
 
gdebiasaCommented:
What I do is use QRLabels to hold my data on the report (as opposed to the data-aware versions). Then, in the OnNeedData event, I put the information from my list (for this record) onto those Captions.

Glen
0
 
hoplaAuthor Commented:
So, I did, and I got the following errors while printing the report:
"Access violation at adress 00415223F in module 'TOP30.EXE'. Read of adres FFFFFFFF."

And...

"A component named QRProgressForm already exists."

What did I do wrong, or can I do to correct it?


Vincent
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
gdebiasaCommented:
My guess is that you're trying to create something dynamically, and trying to create it more than once (hence the "component already exists" you got).

From the information you posted, it's impossible for me to tell you exactly what's wrong. I would try to perform the simplest possible test (like just create the report and destroy it, without using it, for example) to try to narrow down exactly what's causing your access violation (and the other error as well).

Odds are your access violation is caused by trying to reference something that doesn't exist.

Sorry I couldn't be of more help.

Glen
0
 
ZifNabCommented:
hopla,

if you can, show us the code you wrote.

Zif.
0
 
hoplaAuthor Commented:
OK here is the code...
All the QR-stuff, I've placed in/on a separate unit/form.
When printing I call Quick Report from the main unit/form, on this QR_unit.


unit QR_Unit;

interface

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

type
  TForm2 = class(TForm)
    QuickRep1: TQuickRep;
    QRSubDetail1: TQRSubDetail;
    QR_Nr: TQRLabel;
    QR_VW: TQRLabel;
    QR_Titel: TQRLabel;
    QR_Artiest: TQRLabel;
    QRBand1: TQRBand;
    QRDatum1: TQRLabel;
    QR_Promo: TQRLabel;
    QRBand2: TQRBand;
    QR_Copyright: TQRLabel;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    procedure QRBand1BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QRSubDetail1NeedData(Sender: TObject; var MoreData: Boolean);
    procedure QuickRep1BeforePrint(Sender: TQuickRep;
      var PrintReport: Boolean);
    procedure QRBand2BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
  private
    { Private declarations }
    TelRij: Integer;
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.DFM}

procedure TForm2.QRBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
     QRDatum1.Caption:=FormatDateTime('dddd d mmmm yyyy',Form1.DateTimePicker1.Date);
     QR_Promo.Caption:=Form1.PS_Titel.Text+' - '+Form1.PS_Artiest.Text;
end;

procedure TForm2.QRSubDetail1NeedData(Sender: TObject;
  var MoreData: Boolean);
begin
     TelRij:=TelRij+1;

     QR_Nr.Caption:=Form1.TopGrid.Cells[0,TelRij];
     QR_VW.Caption:='('+Form1.TopGrid.Cells[1,TelRij]+')';
     QR_Titel.Caption:=Form1.TopGrid.Cells[2,TelRij];
     QR_Artiest.Caption:=Form1.TopGrid.Cells[3,TelRij];

     MoreData:=TelRij<31;
end;


procedure TForm2.QuickRep1BeforePrint(Sender: TQuickRep;
  var PrintReport: Boolean);
begin
     TelRij:=0;
end;


procedure TForm2.QRBand2BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
     QR_Copyright.Caption:='Mistral Top 30. © Mistral Radio '+FormatDateTime('yyyy',Form1.DateTimePicker1.Date)+'. - Top 30 Wizzard. © HOPLA Software Development 1998, 1999, 2000, ... - Coding: Vincent Verschuren.';
end;

end.




And a piece from the main-unit (I think this will be enough, if not, let me know...)

procedure TForm1.Printpreview1Click(Sender: TObject);
begin
     Form2.QuickRep1.Preview;
end;

procedure TForm1.Print1Click(Sender: TObject);
begin
     Form2.QuickRep1.Print;
end;

procedure TForm1.Printerinstellingen1Click(Sender: TObject);
begin
     Form2.QuickRep1.PrinterSetup;
end;

0
 
ZifNabCommented:
Are you sure your program works if you don't include this unit?
0
 
gdebiasaCommented:
Is Form2 being Auto-created or are you creating it manually?

If it's the latter, are you sure it's been created before you try to access the report? (That would explain the access violation.)

Glen
0
 
hoplaAuthor Commented:
Yes, I'm sure!
The strange thing is, I've disabled the Progress-indicator during the printing, and I've not had the error.

By the way, Form2 is auto-created.

Another thing: "Form2.QuickRep1.PrinterSetup;" does not work!

0
 
ZifNabCommented:
do you use another form called QRProgressForm. Or do you use a component named like that.

Recently upgraded QR? Maybe there is some old-file left or not properly unïnstalled.

Zif.
0
 
hoplaAuthor Commented:
No, but maybe I should?!?
Or do I have to buy the Proffessional version?
0
 
ZifNabCommented:
hi Hopla,
no you don't need to buy the Pro version, but maybe you can get the upgrade version! There are freeware upgrades available at their webpage.

Zif.
0
 
hoplaAuthor Commented:
I'll try it, 'course it still doesn't seem to work!
Still accesviolations... :(
The computer of a friend of mine just hang, while testing my programm...

I'll download the upgrade and will get back to you.
0
 
hoplaAuthor Commented:
I've updated QuickReport, and there are no acces violations anymore during printing.
But there are a few things I still think aren't right:

* When printing, the documents do'n have a name! But I've enterd something in the ReportTitle property.

* Form2.QuickRep1.PrinterSetup; still does not show a printersetup dialog. It should, shouldn't it?

* When closing down, Windows informs me that a nameless task is still active. I think this is a part of QR that doesn't close down properly. Is there a way to "scan" for for undestroyed objects when losing down my programm an do some garbage cleaning?


Hopla
0
 
ZifNabCommented:
hopla, I think you better first totally remove QR and it's accompaning files and then reïnstall it so that you're sure you got all the correct files.
0
 
hoplaAuthor Commented:
From the programm or from Delphi?
Where can I get a file-list?

hopla
0
 
ZifNabCommented:
from both to be fully sure.
0
 
hoplaAuthor Commented:
What I've don is completly removed Delphi and re-installed it and updated QR. Then rebuild the executeble and I've had no problems since! So I think it works now.

Another little question...
How do I get the PrinterSetup-method (and it really shows up now!) to affect the printouts? If I click Printersetup and then set the number of printouts to, let's say 2, it still prints out 1!

hopla
0
 
ZifNabCommented:
Glad it works now. You call it when QR is in preview? Otherwise I don't have a clue, sorry.
0
 
hoplaAuthor Commented:
Well I've got everything working propperly.
Thanks for your help!

Hopla
0
 
ZifNabCommented:
no prob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.