Board index » delphi » TQRGroup Expression using variable

TQRGroup Expression using variable

In a report not connected to a database
I am using OnNeedData to fill field values.
In TQRGroup.Expression I have the
QRLOOPBAND1 variable.

How do I access that variable at run
time to change it so the group breaks?

TIA,
Brad.

 

Re:TQRGroup Expression using variable


hi Brad!
Mr. Italo Gomez helped me with this one.
Since you have defined your own variable in QR, you should:

1- add QRExpr unit in your uses clause (you could explore this unit with
Delphi - there are some usefull functions, although there's only DCU file -
no source with the standard QR)

2- on BeforePrint event of the Group header write something like this:
var
  QREvResult: TQREvResult;
begin
  QREvResult.Kind := resString;
  QREvResult.strResult := NewValueForExpression;
  QuickRep1.Functions.UpdateConstant('MyVariable', QREvResult);
end;

Note that Kind is the type of your data - in this case a string.

Your expression should be declared in the QR expression dialog and the name
of variable should be used for the expression field.
Unfortunately there is no documentation for this one, but it works.
Thanks to Mr. Gomez, we know of it too.
Hope to been helpful.
Stefan

Quote
Brad White <brad_wh...@my-deja.com> wrote in message

news:8aovc4$424@bornews.borland.com...
Quote
> In a report not connected to a database
> I am using OnNeedData to fill field values.
> In TQRGroup.Expression I have the
> QRLOOPBAND1 variable.

> How do I access that variable at run
> time to change it so the group breaks?

> TIA,
> Brad.

Re:TQRGroup Expression using variable


Stefan,

Thanks a lot for your response!  This really helps.
My only problem now is that the expression
appears to be evaluated *before* Group.BeforePrint.

The best place to modify the variable so that
it causes a group break is in the OnNeedData.

Thanks again for the help.
I was stumped.
Brad.

Quote
"Stefan Buynov" <bouy...@yahoo.com> wrote in message

news:8aq6nd$11q6@bornews.borland.com...
Quote
> hi Brad!
> Mr. Italo Gomez helped me with this one.
> Since you have defined your own variable in QR, you should:

> 1- add QRExpr unit in your uses clause (you could explore this unit with
> Delphi - there are some usefull functions, although there's only DCU
file -
> no source with the standard QR)

> 2- on BeforePrint event of the Group header write something like this:

> var
>   QREvResult: TQREvResult;
> begin
>   QREvResult.Kind := resString;
>   QREvResult.strResult := NewValueForExpression;
>   QuickRep1.Functions.UpdateConstant('MyVariable', QREvResult);
> end;

> Note that Kind is the type of your data - in this case a string.

> Your expression should be declared in the QR expression dialog and the
name
> of variable should be used for the expression field.
> Unfortunately there is no documentation for this one, but it works.
> Thanks to Mr. Gomez, we know of it too.
> Hope to been helpful.
> Stefan

> Brad White <brad_wh...@my-deja.com> wrote in message
> news:8aovc4$424@bornews.borland.com...
> > In a report not connected to a database
> > I am using OnNeedData to fill field values.
> > In TQRGroup.Expression I have the
> > QRLOOPBAND1 variable.

> > How do I access that variable at run
> > time to change it so the group breaks?

> > TIA,
> > Brad.

Other Threads