yes but awkward easier to do it in the internal obp event of the memo or the band containing the memo.
Yes I used the report events in FR2, but the FR4 version that comes with XE5 does not give access to events in the report.
It returns Null where ever I seem check the value of the data using
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
v = TfrxMemoView(m).DataSet.Value[TfrxMemoView(m).DataField];
And just returns the field (eg [frxdbDataset.'fieldname']) using
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
m.Text
create a variable in the report connect it to the data field
you can get its value in delphi.
assuming the memo is on masterdata1
use the obp event of the report in delphi
if sender.name = 'Masterdata1'
then
if frxreport1.variables.value = whatever your testing for
then
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
m.visible :=false;
create a variable in the report connect it to the data field
you can get its value in delphi.
assuming the memo is on masterdata1
use the obp event of the report in delphi
if sender.name = 'Masterdata1'
then
if frxreport1.variables.value = whatever your testing for
then
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
m.visible :=false;
Thank you for your help. When the OnBeforePrint code runs I get an 'Invalid variant operation' message at the line with if frxreport1.variables.value = 0 ?
To test I commented out obp code, added the variable into a memo on the data band and it shows the data so variable appears to be OK. So I then edited above line to use a system variable frxreport1.variables.value and got the same message.
I must be missing something subtle here, but I can't see what?
OK I have found the solution. This is such a basis requirement and not in any of the help documents, so here is the solution for anyone else who needs it.
As well as setting the datafield in the Text of the TfrxMemoView, the DataSet and DataField must also be set in the Properties of TfrxMemoView, or the values are not visible from the code.
Delphi OnBeforePrint Code:
If Sender.Name = 'MasterData1' then begin
m := frxReport1.FindObject('Memo1') As TfrxMemoView;
v := TfrxMemoView(m).DataSet.Value[TfrxmemoView(m).DataField];
if v = 0 then
m.Visible := false
else
m.Visible := true;
end
Comments
Yes I used the report events in FR2, but the FR4 version that comes with XE5 does not give access to events in the report.
It returns Null where ever I seem check the value of the data using
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
v = TfrxMemoView(m).DataSet.Value[TfrxMemoView(m).DataField];
And just returns the field (eg [frxdbDataset.'fieldname']) using
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
m.Text
Can you tell me how it is done in delphi code?
you can get its value in delphi.
assuming the memo is on masterdata1
use the obp event of the report in delphi
if sender.name = 'Masterdata1'
then
if frxreport1.variables.value = whatever your testing for
then
m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
m.visible :=false;
Thank you for your help. When the OnBeforePrint code runs I get an 'Invalid variant operation' message at the line with if frxreport1.variables.value = 0 ?
To test I commented out obp code, added the variable into a memo on the data band and it shows the data so variable appears to be OK. So I then edited above line to use a system variable frxreport1.variables.value and got the same message.
I must be missing something subtle here, but I can't see what?
Thanks for your help. I get the same problem though.
As well as setting the datafield in the Text of the TfrxMemoView, the DataSet and DataField must also be set in the Properties of TfrxMemoView, or the values are not visible from the code.
Delphi OnBeforePrint Code:
If Sender.Name = 'MasterData1' then begin
m := frxReport1.FindObject('Memo1') As TfrxMemoView;
v := TfrxMemoView(m).DataSet.Value[TfrxmemoView(m).DataField];
if v = 0 then
m.Visible := false
else
m.Visible := true;
end
Please, how declare variable 'v'?
var v: Variant;