Last report can't be cleared.

Good Day, here is my problem, using the above code i can print my first report correctly, but the next reports are just the same as the first one, after some experimentation i figured out that Report.PrepareReport does not clear the report as it is supposed to do, so what may be the problem ?
Var
  S, TmpName, TmpId: String;
  FrxDataSet: TFrxDBDataSet;
  Report: TFrxReport;
  TmpQ, TmpQ2: TZQuery;
  Stream: TStream;
begin

  TmpName := CurrentEntity.GetEntityName;
  TmpId := IntToStr(GridViewOne.Controller.FocusedRow.Values[0]);

  Report := TFrxReport.Create(FormEntityGrid);
  Report.Clear;

  TmpQ := OpenQuery(Global_Singleton_DbConnection,
    'SELECT REPORT FROM wisp_reports WHERE NAME="' + TmpName +
    '" AND TYPE="SINGLE";').ZQuery;
  Stream := TmpQ.CreateBlobStream(TmpQ.FieldByName('REPORT'), bmRead);
  Stream.Position := 0;
  Report.LoadFromStream(Stream);
  TmpQ.Free;

  S := Global_Singleton_EntityManager.GetEntityByName(TmpName)
    .GetInstanceQueryString(TmpId);

  TmpQ2 := OpenQuery(Global_Singleton_DbConnection, S).ZQuery;

  FrxDataSet := TFrxDBDataSet.Create(Global_Singleton_DbConnection);
  FrxDataSet.UserName := 'Report';
  FrxDataSet.DataSet := TmpQ2;

  Report.DataSets.Items[0].DataSet := FrxDataSet;

  Report.PrepareReport(TRUE);
  Report.ShowReport;

  TmpQ2.Free;

Thanks >

Comments

  • gpigpi
    edited 10:38PM
    Try
    FrxDataSet.Free;
    after
    Report.ShowReport(True);
    comment
    Report.PrepareReport(TRUE);
  • edited 10:38PM
    gpi wrote: »
    Try
    FrxDataSet.Free;
    after
    Report.ShowReport(True);
    comment
    Report.PrepareReport(TRUE);

    Thanks for your reply, but what you suggested does not work > thats because the dataset is actually changing (i cheked the values in debug mode), the problem here is that FastReport is keeping a copy of the last report and use it again and again.
  • edited 10:38PM
    Problem solved after reorganizing my code a little bit, thanks >
      TmpName := CurrentEntity.GetEntityName;
      TmpId := IntToStr(Grid.GridMainView.Controller.FocusedRow.Values[0]);
    
      Report := TFrxReport.Create(FormEntityGrid);
      Report.Clear;
    
      TmpQ := OpenQuery(Global_Singleton_DbConnection,
        'SELECT REPORT FROM wisp_reports WHERE NAME="' + TmpName +
        '" AND TYPE="SINGLE";').ZQuery;
    
      Stream := TmpQ.CreateBlobStream(TmpQ.FieldByName('REPORT'), bmRead);
      Stream.Position := 0;
      Report.LoadFromStream(Stream);
      TmpQ.Free;
    
      S := Global_Singleton_EntityManager.GetEntityByName(TmpName)
        .GetInstanceQueryString(TmpId);
    
      TmpQ2 := OpenQuery(Global_Singleton_DbConnection, S).ZQuery;
    
      FrxDataSet := TFrxDBDataSet.Create(Global_Singleton_DbConnection);
      FrxDataSet.UserName := 'Report';
      FrxDataSet.DataSet := TmpQ2;
    
      Report.DataSets.Items[0].DataSet := FrxDataSet;
    
      Report.PrepareReport(TRUE);
    
      Report.PreviewOptions.Clear;
    
      Report.ShowReport(TRUE);
    
      FrxDataSet.Free;
    
      Report.Clear;
    
      TmpQ2.Free;
    

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.