How To…Use DataModules with ReportBuilder

Question

“Is it possible to use Delphi DataModules with my ReportBuilder application?”

Solution

As a rule of thumb, DataModules should be primarily used to contain abstract data objects such as Tables, Queries, and DataSources.  DataModules are also a good place to place DataPipelines as the TppReport object on the main form of your app will detect all pipelines in the project.

See the example below on the ideal way to use a DataModule with a ReportBuilder application.

Download: UseDataModule.zip

Sample Delphi code:

– Simply add the data module to the “uses” clause of your main form and the TppReport will be able to detect any pipelines present at design time and runtime.

implementation

uses
  MyDataModule;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  //Uncomment if no pipeline is set at design time.
  //ppReport1.DataPipeline := MyDataModule.plCustomers; 
  ppReport1.Print;

end;