Solved

Preview specific record using QReport

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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