Dynamically changing Database

du.64du.64 New Caledonia
edited 3:40AM in FastReport VCL 5
Hi,

I want to print a list of different data on a Report. Threre is 6 differents databases but fields have the same name. So, I intend to use just one Report... I try different possibility and have just the report with the header (Name, Date, Picture). Bands and memos are still on the report (ALAMatrice.fr3).

Code below :

frxRapport.Clear;
// Connection ?  la base de donn?©es du DataModule
DataModule1.frxDbIndication.DataSet := DataModule1.QINDICPL; // The other files are QIndicHE, QIndicGE, QIndicHV, QIndicHA, QIndicTM. Q is for Query.

// Connexion du rapport ?  la base de donn?©es
frxRapport.DataSet := DataModule1.frxDBIndication;
// Ajout aux DataSets
frxRapport.DataSets.Add(DataModule1.frxDBIndication);
frxRapport.EnabledDataSets.Add(DataModule1.frxDBIndication);

//Ouverture du rapport
if frxRapport.LoadFromFile('ALAMatrice.fr3') then
begin
//D?©claration des objets du rapport
Entete1 := frxRapport.FindObject('GroupHeader1') as TfrxGroupHeader;
MemoSys1 := frxRapport.FindObject('SysMemo3') as TfrxSysMemoView;
Maitre1 := frxRapport.FindObject('MasterData1') as TfrxMasterData;
MemoTexte1 := frxRapport.FindObject('Memo1') as TfrxMemoView;
MemoTexte2 := frxRapport.FindObject('Memo5') as TfrxMemoView;
MemoTexte3 := frxRapport.FindObject('Memo6') as TfrxMemoView;
MemoTexte4 := frxRapport.FindObject('Memo7') as TfrxMemoView;
MemoTexte5 := frxRapport.FindObject('Memo8') as TfrxMemoView;

//R?©glage des objets
MemoTexte5.Text := 'PLANTES MEDICINALES';
//Donn?©es
//Entete1.Condition := '[DataModule1.DQIndicPL."Indic"]';
//Entete1.Condition := FrxRapport.AllObjects[0];
MemoSys1.DataSet := DataModule1.frxDbIndication;
MemoSys1.DataField := 'Indic';
//MemoSys1.Memo.Add('DataModule1.DQIndicPL."Indic"');
//Maitre1.DataSet := frxRapport.DataSet;
//Maitre1.DataSet := DataModule1.frxDbIndication;
MemoTexte1.DataSet := DataModule1.frxDbIndication;
MemoTexte1.DataField := 'Nom';
MemoTexte2.DataSet := DataModule1.frxDbIndication;
MemoTexte2.DataField := 'Rem';
MemoTexte3.DataSet := DataModule1.frxDbIndication;
MemoTexte3.DataField := 'VVT';
MemoTexte4.DataSet := DataModule1.frxDbIndication;
MemoTexte4.DataField := 'Organe';
end;

//Pr?©paration et lancement du rapport
if frxRapport.PrepareReport then frxRapport.ShowPreparedReport;

Thanks for help...

Comments

  • gpigpi
    edited 3:40AM
    Try to use TfrxDBDatasets with equal UserName property
  • du.64du.64 New Caledonia
    edited 3:40AM
    gpi wrote: »
    Try to use TfrxDBDatasets with equal UserName property


    Hi Gpi,

    Thanks a lot for your answer.

    I do things as you said. Effectively, it's works. FR prepare 11832 pages with only the header, no data (picture join).

    Do I have to reference DataFields in frxDbReport ? And how ?

    The code's below :

    frxRapport.Clear;
    // Connection ?  la base de donn?©es du DataModule
    DataModule1.frxDbIndication.DataSet := DataModule1.QINDICPL;
    DataModule1.frxDBIndication.UserName := 'PIndic';
    // Connexion du rapport ?  la base de donn?©es
    frxRapport.DataSet := DataModule1.frxDBIndication;
    // Ajout aux DataSets
    frxRapport.DataSets.Add(DataModule1.frxDBIndication);
    frxRapport.EnabledDataSets.Add(DataModule1.frxDBIndication);

    //Ouverture du rapport
    if frxRapport.LoadFromFile('AlaMatrice.fr3') = True then
    begin
    //D?©claration des objets du rapport
    Entete1 := frxRapport.FindObject('GroupHeader1') as TfrxGroupHeader;
    MemoSys1 := frxRapport.FindObject('SysMemo3') as TfrxSysMemoView;
    Maitre1 := frxRapport.FindObject('MasterData1') as TfrxMasterData;
    MemoTexte1 := frxRapport.FindObject('Memo1') as TfrxMemoView;
    MemoTexte2 := frxRapport.FindObject('Memo5') as TfrxMemoView;
    MemoTexte3 := frxRapport.FindObject('Memo6') as TfrxMemoView;
    MemoTexte4 := frxRapport.FindObject('Memo7') as TfrxMemoView;
    MemoTexte5 := frxRapport.FindObject('Memo8') as TfrxMemoView;

    //R?©glage des objets
    MemoTexte5.Text := 'PLANTES MEDICINALES';
    //Donn?©es
    Entete1.Condition := 'DataModule1.frxDbIndication."Indic"';
    MemoSys1.DataSet := DataModule1.frxDbIndication;
    MemoSys1.DataField := 'Indic';
    //Maitre1.DataSet := DataModule1.frxDbIndication;
    MemoTexte1.DataSet := DataModule1.frxDbIndication;
    MemoTexte1.DataField := 'Nom';
    MemoTexte2.DataSet := DataModule1.frxDbIndication;
    MemoTexte2.DataField := 'Rem';
    MemoTexte3.DataSet := DataModule1.frxDbIndication;
    MemoTexte3.DataField := 'VVT';
    MemoTexte4.DataSet := DataModule1.frxDbIndication;
    MemoTexte4.DataField := 'Organe';
    end;

    //Pr?©paration et lancement du rapport
    if frxRapport.PrepareReport then frxRapport.ShowPreparedReport;

    Thanks for your help.

    Best regards

    Patrick
  • gpigpi
    edited 3:40AM
    Create and attach small demo project (report with one masterdata band and one TfrxMemoView) and attach it here
  • du.64du.64 New Caledonia
    edited 3:40AM
    gpi wrote: »
    Create and attach small demo project (report with one masterdata band and one TfrxMemoView) and attach it here

    Hi GPI,

    Thank you for your interest and patience.

    This is not very academic but, because of the common field names, I solved the problem as follows:

    3 : begin
    case RadioGroup3.ItemIndex of
    0 : DataModule1.frxDBTest.DataSet := DataModule1.DQIndicPL.DataSet;
    1 : DataModule1.frxDBTest.DataSet := DataModule1.DQIndicHE.DataSet;
    2 : DataModule1.frxDBIndication.DataSet := DataModule1.DQIndicHV.DataSet;
    3 : DataModule1.frxDBIndication.DataSet := DataModule1.DQIndicHY.DataSet;
    4 : DataModule1.frxDBTest.DataSet := DataModule1.DQIndicTM.DataSet;
    5 : DataModule1.frxDBTest.DataSet := DataModule1.DQIndicGE.DataSet;
    end;

    case RadioGroup3.ItemIndex of
    0, 1, 4, 5 : begin
    frxTest.DataSetName := 'DataModule1.frxDBTest.DataSource';
    frxTest.LoadFromFile('LAAMatrice.fr3');
    end;
    2, 3 : begin
    frxTest.DataSetName := 'DataModule1.frxDBIndication.DataSource';
    frxTest.LoadFromFile('LACMatrice.fr3');
    end;
    end;
    MemoTexte5 := frxTest.FindObject('Memo8') as TfrxMemoView;
    MemoTexte5.Memo.Add(TexteMemo[RadioGroup3.ItemIndex]);
    end;

    So I wrote "hard" the file variables in the file; fr3.

    Thanks a lotu for your help that allowed me to immerse myself in the arcane of FastReport.

    Patrick

  • edited 3:40AM
    du.64 wrote: »
    Hi,

    I want to print a list of different data on a Report. Threre is 6 differents databases but fields have the same name. So, I intend to use just one Report...

    Are you using FireDAC datasets?
  • du.64du.64 New Caledonia
    edited 3:40AM
    weirdo12 wrote: »
    weirdo12 wrote: »
    Hi,

    I want to print a list of different data on a Report. Threre is 6 differents databases but fields have the same name. So, I intend to use just one Report...

    Are you using FireDAC datasets?

    HI,

    No I use Paradox files and Query.
  • edited 3:40AM
    du.64 wrote: »
    HI,

    No I use Paradox files and Query.

    FireDAC has a cool macro feature that would have helped you. You can write a query like:

    SELECT col_1, col_2, col_3 FROM &table_name

    where table_name is a macro whose value can be set at runtime.

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.