Problem changing a color at runtime

Paul CoshottPaul Coshott Western Australia
edited 6:05PM 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 6:05PM
    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.