building report at run time...

How to make report with quickreport in delphi 3 at run time ? Because I want to make report application that generate report which have colomn that equal with fields that selected in SQL command. Can I make TQRDBText component at run time and access all of TQRDBText's properties ? Please, help me.. thank you very much..

Who is Participating?

This is not fully working code but it should be more than enough to get you up and going.
If you have any questions please feel free to ask.

You can also email me at gerhardvr@email.com

var
I: Integer;
begin

For I := 0 to NumberOfColumnsYouNeed do begin
With TQRDBText.Create(Self) do begin
//Now loop to create a QRDBText component for evey one of the fields in your query
//I like to use the field name as the component name prefixed with some text, in
//this case 'qr_'
Name := 'qr_' + WhatEverTheFieldNameIs;
Parent := TheFormNameItBelongsTo //Remember to set this else it won't be visible
Top := YouCalculateTheTopPos;
Left := YouCalculateTheLeftPos;
....... //You now have access to all the properties of the components
end;

//If you need to access any of these components at a later stage to change
//a property you can do it in the following way
With FindComponent('WhatEverTheNameOfTheComponentIs') do begin
Visible := False;
end;

//REMEMBER TO FREE ALL THESE COMPONENTS THAT YOU HAVE CREATED
//WHEN YOURE DONE
For I := 0 to NumberOfColumnsYouNeed do begin
//You have to do this for all the fields in your query since you created
//a component for each of them
With FindComponent('qr_' + WhatEverTheFieldNameIs) do begin
Free;
end;
end;
end;

What he suggests will work except that you don't know how many columns you're going to have at design time preventing you to declare the Field variables before compiling.

The way I suggest is in essence the same at that which Whedhoest suggests except that it allows you to create as many columns as you need at runtime. In this way you don't have to know how many variables you need to declare. As a matter of fact, because of the way the QRDBText components are created ( With TQRDBText.Create(Self) do begin) and accessed at a later stage
(With FindComponent('WhatEverTheNameOfTheComponentIs') do) you don't have to declare variables at all to store the component into.

The method used here makes it totally dynamic which is exactly what you are looking for.