Hiding Child Band based on Memo field contents set from Delphi

Hi,

I have a child Band for my Report Title. On this Child band there is a Memo field, which is not connected to any dataset. The value for this memo field is populated from Delphi by using the following syntax in Delphi itself:
t := TfrxMemoView(frxReportSlip.FindObject('lblCustomerName'));
  if t <> nil then
    t.Memo.Text := (qryFetchHeader.FieldByName('E_CUSTOMERNAME').AsString);

How can I check if the Memo field contains something, and if it does not contain any characters I want the Child band not to display.

I have tried this code on the OBP event in the Fast Report Script, but this does not print anything under any condition.
  if length(lblCustomerName.value)<1 then           
    begin
      Child2.Visible := False;
      Child2.Height  := 0.00;                                                            
    end
  else
    begin
      Child2.Visible := True;
      Child2.Height  := 1.13;        
    end;

Your assistance much appreciated.

Regards
Marius

Comments

  • edited 5:38AM
    I don't know if this is the correct way to do it, but this seems to be working for me.

    From within my Delphi code, I use this:
      if length(qryFetchHeader.FieldByName('E_CUSTOMERNAME').AsString)>0 then
        begin
          frxReportSlip.FindObject('Child2').Visible := True;
          t := TfrxMemoView(frxReportSlip.FindObject('lblCustomerName'));
          if t <> nil then
            t.Memo.Text := (qryFetchHeader.FieldByName('E_CUSTOMERNAME').AsString);
          t := TfrxMemoView(frxReportSlip.FindObject('lblCustomerVATNo'));
          if t <> nil then
            t.Memo.Text := (qryFetchHeader.FieldByName('E_VATNumber').AsString);
        end
      else
        begin
          frxReportSlip.FindObject('Child2').Visible := False;
        end;
    

    Any comments?
  • edited 5:38AM
    Marius wrote: »
    I have tried this code on the OBP event in the Fast Report Script, but this does not print anything under any condition.
      if length(lblCustomerName.value)<1 then           
        begin
          Child2.Visible := False;
          Child2.Height  := 0.00;                                                            
        end
      else
        begin
          Child2.Visible := True;
          Child2.Height  := 1.13;        
        end;
    

    I would try:
      if length(trim(lblCustomerName.text)) < 1 then           
        begin
          Child2.Visible := False;
    //      Child2.Height  := 0.00;    // not need for this if visible is false                                                        
        end
      else
        begin
          Child2.Visible := True;
    //      Child2.Height  := 1.13;        
        end;
    

    As far as I know, the value-property is for use in the OnAfterData of the memo only, and does not contain anything otherwise.

    Petter
  • edited 5:38AM
    Maybe you could follow that

    Child2.Visible := Trim(lblCustomerName.text) <> ''

    and that code (FR script) should be executed in OBP event of Report Title, eg. before its Child band is analised by FR Engine.

    Regards
    Mick

  • gpigpi
    edited 5:38AM
    Try Child2.Visible := Trim(<YourDatasetName."YourFieldName">) <> ''
    or Child2.Visible := Trim(Report.Calc(lblCustomerName.text)) <> ''

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.