1 (edited by aavila 2019-03-22 21:33:34)

Topic: Report by script no load datasets

I try to make a report by script but the dataset is not loader, idk why, i follow some examples and topics in this forum but still not work

This is my code:

procedure frmMain_Button10_OnClick (Sender: TObject; var Cancel: boolean);
var
    frxDBDataSet1, frxDBDataSet2, frxDBDataSet3 : TfrxDBDataset;
    Results1, Results2, Results3 : TDataSet;
    asset_id : Integer;
begin
    //the variable I need to trigger the queries
    asset_id := frmMain.TableGrid1.dbItemID;

      //qyery one stored in dataset1
      SQLQuery('SELECT * FROM proposal WHERE proposal.id = "'+IntToStr(asset_id)+'"', Results1);

        //query two stored in dataset 2
        SQLQuery('SELECT * FROM quoting WHERE id_proposal = "'+IntToStr(asset_id)+'"', Results2);

      //query three stored in dataset 3
      SQLQuery('SELECT * FROM annex WHERE id_proposal = "'+IntToStr(asset_id)+'"', Results3);


    //transfer standard datasets results to report datasets
    frxDBDataSet1 := TfrxDBDataset.Create(frmMain);
    frxDBDataSet1.UserName := 'Proposal';
    frxDBDataSet1.CloseDataSource := True;
    frxDBDataSet1.OpenDataSource := True;
    frxDBDataSet1.DataSet := Results1;

    frxDBDataset2 := TfrxDBDataset.Create(frmMain);
    frxDBDataset2.UserName := 'Quoting';
    frxDBDataset2.CloseDataSource := True;
    frxDBDataset2.OpenDataSource := True;
    frxDBDataset2.DataSet := Results2;

    frxDBDataset3 := TfrxDBDataset.Create(frmMain);
    frxDBDataset3.UserName := 'Annex';
    frxDBDataset3.CloseDataSource := True;
    frxDBDataset3.OpenDataSource := True;
    frxDBDataset3.DataSet := Results3;


    //assign the three report datasets to the same report
    frmLogin.frxReport.Clear;
    frmLogin.frxReport.DataSets.Clear;
    frmLogin.frxReport.DataSets.Add(frxDBDataSet1);
    frmLogin.frxReport.DataSets.Add(frxDBDataset2);
    frmLogin.frxReport.DataSets.Add(frxDBDataset3);

    //DESIGN MODE - comment the following two lines and uncomment the preview mode lines to preview report

    frmLogin.frxReport.LoadFromFile('.\Report\prop.fr3');
    frmLogin.frxReport.DesignReport;


    //PREVIEW MODE - comment the following four lines and uncomment the above design mode lines to design report

    //frxDBDataset1.DataSet.Close;
    //frxDBDataset2.DataSet.Close;
    //Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\MyReport.fr3'); //this is my path and my report name, you need to use yours
    //Form1.frxReport.ShowReport;

    Results1.Free;
    frxDBDataSet1.Free;
    Results2.Free;
    frxDBDataset2.Free;
    Results3.Free;
    frxDBDataset3.Free;

    frmLogin.frxReport.Clear;
    frmLogin.frxReport.DataSets.Clear;
end;

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=5227&download=0




This report button is in the second form in my project, thanks in advanced

Post's attachments

Attachment icon Anotación 2019-03-22 161125.png 127.05 kb, 69 downloads since 2019-03-22 

Re: Report by script no load datasets

Hello.


You should select these datasets from menu: Report > Data

Dmitry.