Two reports in the same form using two frxPreview components

Hi All!

In an app I want to show two reports in the same form.

I split the form in two sections using two panels and in each panel I put two frxPreview components 

// Properties of 1st report

frxDBDataset1.DataSet := QEvCurrent1;

frxDBDataset1.UserName := 'frxDBDataset1';

frxReport1.DataSet := frxDataSet1;

frxReport1.DataSetName := 'frxDBDataset1';

frxReport1.Preview := nil; // See note 

// Properties os 2nd report

frxDBDataset2.DataSet := QEvCurrent2;

frxDBDataset2.UserName := 'frxDBDataset2';

frxReport2.DataSet := frxDataSet2;

frxReport2.DataSetName := 'frxDBDataset1';

frxReport2.Preview := nil; // See note 

 QEvCurrent1.Active := False;

 QEvCurrent1.SQL.Clear;

 QEvCurrent1.SQL.Add('SELECT TOP 3 * FROM Cars WHERE Maker = ''Ford'' ORDER BY Model DESC');

 QEvCurrent1.Active := True;

 if frxReport1.LoadFromFile('C:\Projects\Cars\DashBReport1.fr3') then

  begin

   if frxReport1.PrepareReport(True) then

    begin

     frxReport1.Preview := frxPreview1;

     frxReport1.ShowPreparedReport;

     ShowMessage('Preview 1: ' + frxPreview1.Report.Name);    // <= Shows DashBReport1

    end

   else

    MessageDlg('Error Preparing Report 1', mtError, [mbOk], 100);

  end

 else

  MessageDlg('Error Loading Report 1', mtError, [mbOk], 100);


 QEvCurrent2.SQL.Clear;

 QEvCurrent2.SQL.Add('SELECT TOP 3 * FROM Cars WHERE Maker = ''BMW'' ORDER BY Model DESC');

 QEvCurrent2.Active := True;

 if frxReport2.LoadFromFile('C:\Projects\\Cars\DashBReport2.fr3') then

  begin

   frxReport2.Preview := frxPreview2;

   if frxReport2.PrepareReport(True) then

    begin

     frxReport2.Preview := frxPreview2;

     frxReport2.ShowPreparedReport;

     ShowMessage('Preview 2: ' + frxPreview2.Report.Name);    // <= Shows DashBReport2

    end

   else

    MessageDlg('Error Preparing Report 2', mtError, [mbOk], 100);

  end

 else

  MessageDlg('Error Loading Report 2', mtError, [mbOk], 100);


But the forms shows data for Ford cars in both reports and I'm sure there are data in the second query

Is ti possible to do this wir FR?

Best Regards

Francisco Alvarado

Note:

https://forum.fast-report.com/en/discussion/16478/two-reports-into-one-preview-fr-fmx/p1

Comments

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.