?
Solved

Preview specific record using QReport

Posted on 2002-05-02
5
Medium Priority
?
252 Views
Last Modified: 2010-04-04
Hi all,

How can I like to preview a specific record using QReport?
If I use QReport1.Preview, this previews from the beginning of the database. Is there a way to preview
eg. the third record?

Thanks,
Freerider.
0
Comment
Question by:Freerider
[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 Comments
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6986911
Maybe you can set the Filter-Property of the Table you use. Also set the Filtered-property to true.

I you quit the report, set the table back to filtered:=false


0
 
LVL 6

Accepted Solution

by:
wimmeyvaert earned 200 total points
ID: 6986936
A little example :

First be sure to have a Form + Report.
Make sure you linked the DataSet of the report to the same dataset you use on your form (in my example Table1)

Then,when the user clicks on a button on the form, the report is showed, and only the current record should appear on the report, cause my dataset is filtered.

After the report is closed, I clear the filter.



procedure TForm1.Button1Click(Sender: TObject);
begin
  // be sure the DataSet of the reports is linked to the DataSet of my Form.
  Form1.Table1.DisableControls;
  Form1.Table1.Filter := 'Id='+Table1.FieldByName('ID').AsString;
     Form1.Table1.Filtered := True;
     QuickReport2 := TQuickReport2.Create(Self);
  QuickReport2.Previewmodal;
  FreeAndNil(QuickReport2);
  Form1.Table1.Filter := '';
     Form1.Table1.Filtered := False;
  Form1.Table1.EnableControls;
end;
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6987947
Hi Freerider,
take a look at TQRBand.BeforePrint event. There is PrintBand variable that can be set to false to skip printing this band. Yuo just need to do something like this:

1. TQuickRep.BeforePrint reset some integer variable to zero.
2. TQRBand.BeforePrint

begin
   inc(SomeValue);
   PrintBand := SomeValue > 3;
end;

-------
Igor.
0
 
LVL 1

Expert Comment

by:trex_fire
ID: 6989879
Or just use a TQuery specifying the exact data you wich to show in your report. You can modifiy at run time the SQL property for more flexibility.
Like:

Query.Close;
Query.SQL.Clear;
Query.SQL.Add('Select * from mytable where myId = :ID');
Query.ParamByName('ID').AsInteger := IdToShow;
Query.Open;
Report.Preview;

T-Rex
0
 

Author Comment

by:Freerider
ID: 6999739
works great - Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 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