Problem changing a color at runtime

Paul CoshottPaul Coshott Western Australia
edited 4:04AM in FastReport VCL
Hi All,

I am trying to change the background color of a MasterData band, but keep getting an error.

In my Delphi app, I am using the reports OnBeforePrint to setup a variable:
procedure TForm1.XRepBeforePrint(Sender: TfrxReportComponent);
begin
  XRep.Variables.Clear;
  XRep.Variables['iStaff'] := 7;
end;

Then the script inside my report is this:
procedure mdDay0OnBeforePrint(Sender: TfrxComponent);
begin
  if <DayPanel0."StaffId"> = <iStaff> then begin
    mdDay0.Fill.BackColor := $003E9EFF;
  end else begin                                        
    mdDay0.Fill.BackColor := clNone;  
  end;                                          
end;

*** mdDay0 is the MasterData band. This is a report, with 7 sub reports. mdDay0 is on the first sub report.

I am getting the following error when I run the report.

The following error(s) have occured:
Script error at 4:26: Could not convert variant of type (Null)
into type (Integer)

I have tried putting the $003E9EFF inside quotes, and have tried using clRed, but I get the same error.

How should I do this?

Thanks,
Paul

Comments

  • edited 4:04AM
    My guess is your error is in the if statement.
    Did you set iStaff as a variable in the report editor? If not it could still be NULL even when you set it.

Leave a Comment