Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use variables in QReports ?

Status
Not open for further replies.

wrov

Programmer
Nov 1, 2002
43
PY
Hello everybody

Do you know how to use variables in QRreports ?

By example: if I had a var named CustomerCode in the file Customer.pas, how can I use it in a report (in the Title band) ?

Thanks in advance

Walter.
 
U should put the value in the title property of the QR, then use a QRLabel, and change the type for QRTitle
 
I dont understand or you dont understand:

The value is EXTERNAL to the Qreport. I had it in another unit.

I want to use an external variable in a QReport. Is it possible ?

Walter.
 
Yes you can do that, but first you must include to your application the unit where the external variable is located with the "uses" this way you can make a reference of your object in the application
 
This variable CustomerCode looks to me like something that is in a table but ..

My advice, make use of Datamodules. Put your tables and querys on the Datamodules and and also every global variable you want to use somewhere in your program.
The Datamodule is a container for non visual components like tables, datasources, imagelists, stringlists and your own non-visual variables. Steven van Els
SAvanEls@cq-link.sr
 
Yes, I know all that but...

it still doesnt work !!!

I had included the unit where the external variable is located but it doesnt work.

I use DataModule but... it doesnt work

Some another suggestion ?

Walter
 
Give some more details!!! Steven van Els
SAvanEls@cq-link.sr
 
Well ...

In the first place, my English is not very good so excuse me if you dont understand something.

The fact is very simple after all:

How can you use a value (const or var) for to print in a QReport if the value is declared in another unit (.pas) ?

I had tried many things but nothing works. Of course the first try was to put the name of the unit where I declared the value in the "uses" clause of the unit where the QReport is located. I try declaring the value in the "interface" section (it's logic, right ?), later in the "implementation" section (just for try), but ... it doesnt works.

I suppose that could have some way. There is ?

Thanks in advance.

Walter.
 
QuickReport like any report generator works with text.
If you have a value, convert it to text and use a QRlabel. Use the caption property. Steven van Els
SAvanEls@cq-link.sr
 
Walter,
pls explain where your variable is.
You may want to place it in a table and then point to it in qr by setting dataset and the field value. Give more details...
yomyom
 
A different approach would be to pass the data your report needs as parameters. In the following snippet of code, I pass a year to my report.

try
if cbxYear.Text = '' then begin
MessageDlg('The Year Needs to be Selected', mtError, [mbok], 0);
cbxYear.SetFocus;
Exit;
end;
RPrEstBilled := TRPrEstBilled.Create(Application);
dmPrEstBilled := TdmPrEstBilled.Create(Application);
RPrEstBilled.Execute(StrToInt(cbxYear.Text));
finally
RPrEstBilled.Free;
dmPrEstBilled.Free;
end;

Hope that helps!?

Peter Tickler
 
Use the wonderful delphi debugger to find the value of the variable before it is used...
 
Put the unitname(Customer in your example) where your in the used of the form where you call the report, then
Put a QRLabel into the Title band and then
From the form where you show the report before show the report do:
QuickReport1.QRLabel1.Caption:=Customer.VariableName; Camilo Andrés Sánchez A.
Ingeniería de Sistemas
Pontificia Universidad Javeriana
Bogotá, Colombia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top