Solved

Preview specific record using QReport

Posted on 2002-05-02
5
246 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
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 50 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now