Solved

building report at run time...

Posted on 1998-12-01
5
474 Views
Last Modified: 2010-04-04
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..
0
Comment
Question by:whedhoest
[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
  • 3
5 Comments
 

Author Comment

by:whedhoest
ID: 1348870
Edited text of question
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1348871
Hi whedhoest,

It's posible to create a TQRDBText component at runtime.
Something like this will get you started

var
  qrSomeField :TQRDBText;
begin
  qrSomeField := TQRDBText.Create(nil);
  qrSomeField.Dataset := yourDataset;
  qrSomeField.Datasource := yourDatasource;
  ...........
  ...........
  qrSomeField := nil;
end;

Sorry don't have the time right now to work this out in more detail, but this should get you in the right direction.

PS. if you like I will give it a better look at the other side of the day.


0
 
LVL 1

Accepted Solution

by:
Gerhard100198 earned 200 total points
ID: 1348872
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;
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348873
Just had a look at Whedhoest comment.

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.
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348874
Need to correct the code I submitted in the answer:

Because FindObject return a TObject you will need to typecast the result to be able to get access to it's properties

Examle for the above code:

  With TQRDBText(FindComponent('WhatEverTheNameOfTheComponentIs')) do begin
          Visible := False;
  end;

AND

   With TQRDBText(FindComponent('qr_' + WhatEverTheFieldNameIs)) do begin
           Free;
   end;
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month7 days, 13 hours left to enroll

632 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