Merge Reports

I am trying to take two seperate reports and print them together. I have been searching the forums and web and have tried everything. However, when I go to print the report it's just showing me the last report. I have tested the code individually and each report works on it's own but not when I try to combine them.
     { Print for files }
      frxRptMain := TfrxReport.Create(nil);
      frxRptMain.EngineOptions.DoublePass:= true;
      frxRptMain.FileName := 'RenewalPackage_'+fBondNbr;


      if frxRptNotice <> nil then FreeAndNil(frxRptNotice);
      frxRptNotice := TfrxReport.Create(nil);
      frxRptNotice.LoadFromFile(ExtractFileDir(application.ExeName) + '\FastReport\procrptNotice.fr3');
      tOrigQry := Trim(TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text);
      TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text := tOrigQry + ' where BondNo = ''' + fBondNbr + ''' ' +
        ' and SessionID = ''' + IntToStr(fSessionID) + ''' ';
      frxRptNotice.PrepareReport(False);

      fMemStm := TMemoryStream.Create;
      frxRptNotice.SaveToStream(fMemStm, True, True, True);
      fMemStm.Position := 0;
      frxRptMain.LoadFromStream(fMemStm);
      fMemStm.Free;
      //frxRptMain.PrepareReport(False);

      if frxRptSummary <> nil then FreeAndNil(frxRptSummary);
      frxRptSummary := SetupReport(ExtractFileDir(application.ExeName) + '\FastReport\Bond Summary.fr3',[fBondNbr,'Y',edtPrintDate.Date]);
      frxRptSummary.PrepareReport(False);

      fMemStm := TMemoryStream.Create;
      frxRptSummary.SaveToStream(fMemStm, True, True, True);
      fMemStm.Position := 0;
      frxRptMain.LoadFromStream(fMemStm);
      fMemStm.Free;

      frxRptMain.PrepareReport(False);

Comments

  • edited 8:23PM
    jfgreco wrote: »
    I am trying to take two seperate reports and print them together. I have been searching the forums and web and have tried everything. However, when I go to print the report it's just showing me the last report. I have tested the code individually and each report works on it's own but not when I try to combine them.
         { Print for files }
          frxRptMain := TfrxReport.Create(nil);
          frxRptMain.EngineOptions.DoublePass:= true;
          frxRptMain.FileName := 'RenewalPackage_'+fBondNbr;
    
    
          if frxRptNotice <> nil then FreeAndNil(frxRptNotice);
          frxRptNotice := TfrxReport.Create(nil);
          frxRptNotice.LoadFromFile(ExtractFileDir(application.ExeName) + '\FastReport\procrptNotice.fr3');
          tOrigQry := Trim(TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text);
          TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text := tOrigQry + ' where BondNo = ''' + fBondNbr + ''' ' +
            ' and SessionID = ''' + IntToStr(fSessionID) + ''' ';
          frxRptNotice.PrepareReport(False);
    
          fMemStm := TMemoryStream.Create;
          frxRptNotice.SaveToStream(fMemStm, True, True, True);
          fMemStm.Position := 0;
          frxRptMain.LoadFromStream(fMemStm);
          fMemStm.Free;
          //frxRptMain.PrepareReport(False);
    
          if frxRptSummary <> nil then FreeAndNil(frxRptSummary);
          frxRptSummary := SetupReport(ExtractFileDir(application.ExeName) + '\FastReport\Bond Summary.fr3',[fBondNbr,'Y',edtPrintDate.Date]);
          frxRptSummary.PrepareReport(False);
    
          fMemStm := TMemoryStream.Create;
          frxRptSummary.SaveToStream(fMemStm, True, True, True);
          fMemStm.Position := 0;
          frxRptMain.LoadFromStream(fMemStm);
          fMemStm.Free;
    
          frxRptMain.PrepareReport(False);
    

    Try frxRptMain.PreviewPages.LoadFromStream(fMemStm) to build compound report.


  • gpigpi
    edited June 2015
    if frxRptNotice <> nil then FreeAndNil(frxRptNotice);
    frxRptNotice := TfrxReport.Create(nil);
    frxRptNotice.LoadFromFile(ExtractFileDir(application.ExeName) + '\FastReport\procrptNotice.fr3');
    tOrigQry := Trim(TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text);
    TfrxADOQuery(frxRptNotice.DataSets[0].DataSet).SQL.Text := tOrigQry + ' where BondNo = ''' + fBondNbr + ''' ' +
    ' and SessionID = ''' + IntToStr(fSessionID) + ''' ';
    frxRptNotice.PrepareReport(True);

    frxRptNotice.LoadFromFile(ExtractFileDir(application.ExeName) + '\FastReport\Bond Summary.fr3');
    frxRptNotice.PrepareReport(False);

    frxRptNotice.ShowPreparedReport;[/code]

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.