Solved

Preview specific record using QReport

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

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month7 days, 9 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