Board index » delphi » QR Expression

QR Expression

Hi: Using QR with D6 Ent and am probably pushing the expression formula to the
limit.  What I'm trying to do is to set a mask on a data field, depending on
another table field.  The field in question is in a FF table and the field is a
floating point field called "iprice" and the controlling field is an integer
field called "optip".  If the value of optip is < 7, I want to set a mask on the
iprice field to "XXX.00" and if it's >= 7, the iprice mask should be set to
"XXX.00000".  I tried entering the following in the detail band:

                   if(optip<7,iprice.mask=###.00,iprice.mask=###.00000)

but no luck.  Any ideas?

Thanks in advance for looking into it
Joe Krusick

 

Re:QR Expression


Hi Joe,
you'd be better off doing the same thing in "onprint of optip (label or
DBText)" or "beforeprint of the band". Here's how it'd work:

1. using Onprint of optip:
procedure TForm1.optipPrint(sender: TObject; var Value: String);
// note that the "value" here is the value that it'd print..i.e.
// the field's value.. It always prints as a string.
begin
  if strtoint(Value) < 7 then
    iprise.mask:=###.00
  else
    iprice.mask:=###.00000;
end;
2. using Beforeprint of the band:
procedure TForm1.BandBeforePrint(Sender: TQRCustomBand;var PrintBand:
Boolean);
// no "value" is available here.. so we need to refer the datafield
// directly
begin
   if FF.FieldByName('optip').AsInteger < 7 then
    iprise.mask:=###.00
  else
    iprice.mask:=###.00000;
end;

Expressions are used "generally" to print a "calculated value" or a
conditional calculated values rather than manipulating the other
components print behaviour. :-)
hope this helps
Best regards
Dhaval Shah
Sr. Software Developer
Perth, Australia

Quote
Joe Krusick wrote:
> Hi: Using QR with D6 Ent and am probably pushing the expression formula to the
> limit.  What I'm trying to do is to set a mask on a data field, depending on
> another table field.  The field in question is in a FF table and the field is a
> floating point field called "iprice" and the controlling field is an integer
> field called "optip".  If the value of optip is < 7, I want to set a mask on the
> iprice field to "XXX.00" and if it's >= 7, the iprice mask should be set to
> "XXX.00000".  I tried entering the following in the detail band:

>                    if(optip<7,iprice.mask=###.00,iprice.mask=###.00000)

> but no luck.  Any ideas?

> Thanks in advance for looking into it
> Joe Krusick

Re:QR Expression


Hi Mr. Shah:  Thank you for responding to my question. Tried both your methods and
they both error out when I do the compile.  Some reason or another, it doesn't like
the "iprice.mask :=###.00" or the "iprice.mask=###.00000" in both methods. Compiler
says iprice is an Undeclared Identifier, the part of the expression ### "constant
expression expected, and ......
.  Seems that it should work, but doesn't compile.

Thanks again
Joe Krusick

Quote
Dhaval Shah wrote:
> Hi Joe,
> you'd be better off doing the same thing in "onprint of optip (label or
> DBText)" or "beforeprint of the band". Here's how it'd work:

> 1. using Onprint of optip:
> procedure TForm1.optipPrint(sender: TObject; var Value: String);
> // note that the "value" here is the value that it'd print..i.e.
> // the field's value.. It always prints as a string.
> begin
>   if strtoint(Value) < 7 then
>     iprise.mask:=###.00
>   else
>     iprice.mask:=###.00000;
> end;
> 2. using Beforeprint of the band:
> procedure TForm1.BandBeforePrint(Sender: TQRCustomBand;var PrintBand:
> Boolean);
> // no "value" is available here.. so we need to refer the datafield
> // directly
> begin
>    if FF.FieldByName('optip').AsInteger < 7 then
>     iprise.mask:=###.00
>   else
>     iprice.mask:=###.00000;
> end;

> Expressions are used "generally" to print a "calculated value" or a
> conditional calculated values rather than manipulating the other
> components print behaviour. :-)
> hope this helps
> Best regards
> Dhaval Shah
> Sr. Software Developer
> Perth, Australia

> Joe Krusick wrote:
> > Hi: Using QR with D6 Ent and am probably pushing the expression formula to the
> > limit.  What I'm trying to do is to set a mask on a data field, depending on
> > another table field.  The field in question is in a FF table and the field is a
> > floating point field called "iprice" and the controlling field is an integer
> > field called "optip".  If the value of optip is < 7, I want to set a mask on the
> > iprice field to "XXX.00" and if it's >= 7, the iprice mask should be set to
> > "XXX.00000".  I tried entering the following in the detail band:

> >                    if(optip<7,iprice.mask=###.00,iprice.mask=###.00000)

> > but no luck.  Any ideas?

> > Thanks in advance for looking into it
> > Joe Krusick

Re:QR Expression


Hi Joe,
1. iprice in my example is a QRLabel / TQRDBEdit component's name. you'd
have to replace it with whatever component you want to assign the mask to.
2. mask is a string. So, to assign it (my mistake) you have to enclose
it in single quotes.
eg.
iprice.mask:= '###.00';
this'd get it compiled..
cheers
Dhaval Shah
Sr. Software Developer
Perth, Australia
Quote
Joe Krusick wrote:
> Hi Mr. Shah:  Thank you for responding to my question. Tried both your methods and
> they both error out when I do the compile.  Some reason or another, it doesn't like
> the "iprice.mask :=###.00" or the "iprice.mask=###.00000" in both methods. Compiler
> says iprice is an Undeclared Identifier, the part of the expression ### "constant
> expression expected, and ......
> .  Seems that it should work, but doesn't compile.

> Thanks again
> Joe Krusick

> Dhaval Shah wrote:

>>Hi Joe,
>>you'd be better off doing the same thing in "onprint of optip (label or
>>DBText)" or "beforeprint of the band". Here's how it'd work:

>>1. using Onprint of optip:
>>procedure TForm1.optipPrint(sender: TObject; var Value: String);
>>// note that the "value" here is the value that it'd print..i.e.
>>// the field's value.. It always prints as a string.
>>begin
>>  if strtoint(Value) < 7 then
>>    iprise.mask:=###.00
>>  else
>>    iprice.mask:=###.00000;
>>end;
>>2. using Beforeprint of the band:
>>procedure TForm1.BandBeforePrint(Sender: TQRCustomBand;var PrintBand:
>>Boolean);
>>// no "value" is available here.. so we need to refer the datafield
>>// directly
>>begin
>>   if FF.FieldByName('optip').AsInteger < 7 then
>>    iprise.mask:=###.00
>>  else
>>    iprice.mask:=###.00000;
>>end;

>>Expressions are used "generally" to print a "calculated value" or a
>>conditional calculated values rather than manipulating the other
>>components print behaviour. :-)
>>hope this helps
>>Best regards
>>Dhaval Shah
>>Sr. Software Developer
>>Perth, Australia

>>Joe Krusick wrote:

>>>Hi: Using QR with D6 Ent and am probably pushing the expression formula to the
>>>limit.  What I'm trying to do is to set a mask on a data field, depending on
>>>another table field.  The field in question is in a FF table and the field is a
>>>floating point field called "iprice" and the controlling field is an integer
>>>field called "optip".  If the value of optip is < 7, I want to set a mask on the
>>>iprice field to "XXX.00" and if it's >= 7, the iprice mask should be set to
>>>"XXX.00000".  I tried entering the following in the detail band:

>>>                   if(optip<7,iprice.mask=###.00,iprice.mask=###.00000)

>>>but no luck.  Any ideas?

>>>Thanks in advance for looking into it
>>>Joe Krusick

Other Threads