I've used File -> Variable List to define a new variable (just the name) and used Type -> Other -> Expression. I set the default value to 1.
I then double clicked on a header memo field and enabled the Script
checkbox, and typed in the following code in the Script box:
if [HideKlas] = 1 then
Visible := False;
If I preview the report now it works as expected, the column is hidden. Changing the variable's hard-coded value to 0, and the column becomes visible in the preview. So far so good.
Now to try and set the variable from my application code. In my *.pas unit I temporarily tried to set a hard-coded value of the
"HideKlas" variable to see what happens in the report. I tried both the
values '0' and '1'.
If FRPrint.PrepareReport then
begin
FRPrint.Variables.Values['HideKlas'] := '1'; // for testing only
FRPrint.Preview := FAfdrukForm.PrintPanel;
FRPrint.ShowPreparedReport;
end;
No matter what I do, the header (memo) field is not affected. It seems to always use the hard-coded value as I defined it when I created the variable in the report designer.
So I made a little progress, but still stuck. :-(