Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

building report at run time...

Posted on 1998-12-01
5
Medium Priority
?
476 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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

688 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