1 (edited by teco049 2017-02-15 08:16:50)

Topic: SOLVED: Access to multible tables

Hi,
Is it possible to use more as one table on a report which are NOT connected by reference.

Example:
I have a table with categories and a "setting" table with various static information like company name, address, etc.
Both tables are not connected by reference.

Is it possible to use both tables independent in a report?

The setting table for header information and the category table for the master band with the list of categories?

Thank you.

2 (edited by ehwagner 2017-02-02 17:07:11)

Re: SOLVED: Access to multible tables

Welcome to MVD.


I learned the technique in the attached from Dimitry in this forum. I know sometimes it is difficult to find things on the forum because the solutions are not always under the keywords you think they should be. I usually will download solutions as they are presented even if I don't need it immediately. This way I have a local reference that I can find easier in the future when I do need it.

In the attached project pay attention to the design mode and preview mode in the script. You have to control which mode you want within the script. Hope this solution is what you are looking for.

Post's attachments

Attachment icon Report Two Tables.zip 583.47 kb, 653 downloads since 2017-02-02 

Re: SOLVED: Access to multible tables

Hello ehwagner,
looks like the part I am looking for.
Thank you.

4 (edited by teco049 2017-02-14 16:02:51)

Re: SOLVED: Access to multible tables

I have a misunderstanding problem.

I get always a error message "undecleared identifie: 'frxReport'" on the line

Form1.frxReport.Clear;

I have renamed it to

Berichte.frxReport.Clear

Because all Printings are on "Berichte".

Where is the "frxReport" delcared? I have nothing found at the sample script

procedure Form1_Button4_OnClick (Sender: string; var Cancel: boolean);
var
    frxDBDataset1, frxDBDataset2: TfrxDBDataset;
    Results1, Results2: TDataSet;
  begin

    // Data for first dataset
    SQLQuery('SELECT * FROM Settings where id = 1', Results1);

    // Data for second dataset
    SQLQuery('SELECT * FROM Categories' , Results2);

    // create first DataSet
    frxDBDataset1 := TfrxDBDataset.Create(Form1);
    frxDBDataset1.UserName := 'Report1';
    frxDBDataset1.CloseDataSource := True;
    frxDBDataset1.OpenDataSource := True;
    frxDBDataset1.DataSet := Results1;

    // create second DataSet
    frxDBDataset2 := TfrxDBDataset.Create(Form1);
    frxDBDataset2.UserName := 'Report2';
    frxDBDataset2.CloseDataSource := True;
    frxDBDataset2.OpenDataSource := True;
    frxDBDataset2.DataSet := Results2;

    // set up report
    Form1.frxReport.Clear;                                                
    Form1.frxReport.DataSets.Clear;
    Form1.frxReport.DataSets.Add(frxDBDataset1);
    Form1.frxReport.DataSets.Add(frxDBDataset2);


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

    Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\MyReport.fr3');
    Form1.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');
    //Form1.frxReport.ShowReport;


    frxDBDataset1.Free;
    frxDBDataset2.Free;
end;

begin

end.

And there is no button definied as for printing on the forms.

Any Idea what I am missing?

Re: SOLVED: Access to multible tables

Problem solved.

For whatever reason you must use the Name of the first form in you application. Any other form has not the Object frxReport.
.
If you have renamed this form you must use the renamed name.
.
.
Example:
Original formname:
Form1.frxReport.clear
.
Renamed Form1 to ThisIsMyLargeFormNameWithoutSpaces
ThisIsMyLargeFormNameWithoutSpaces.frxReport.clear
.
The sample of ehwagner must be adjusted to whatever name you have renamed your first Window form.