Solved

Preview specific record using QReport

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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 video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

21 Experts available now in Live!

Get 1:1 Help Now