Data

Within the work environment of the Data tab, end users can quickly create dataviews, which can then be used to supply data to reports. Dataviews are usually created via the Query Wizard or Query Designer. Both of these tools are visual they also allow the end user to select the tables, fields, search criteria, and sort order necessary for the report. Behind the scenes, an SQL statement is generated and used to retrieve the data from the database. A screen shot of a completed dataview is shown...

Dataview

A dataview presents what appears to be a single set of data to the end user. in reality, the dataview may be composed of one or many Delphi data access components. The implementation of a dataview can be as simple as a single SQL query, or as complex as a set of linked tables. Whatever the implementation, the dataview always appears the same to the end user, and the implementation always depends upon the choices you make as a developer. Dataviews interface with the other workspaces within the...

Run the Create Tables SQL Script

1 Select Database Explore from the Delphi main menu to access the Database Explorer. 5 Select 'File Run an ISQL Script' from the main menu of the InterBase ISQL utility. Open the ExploreTables.sql file. A 'Save output to a file ' dialog will be displayed. 2 Double-click the database alias corresponding to your Interbase database. The alias for a default installation of the local InterBaser server is IBLO-CAL. * create Item table * CREATE TABLE rb_item (item_id INTEGER, folder_id INTEGER, name...

Configure the Page Size and Bands

1 Double-click on the Report component to display the Report Designer. 2 Size and move the Report Designer window so that the Object Inspector is visible. 3 Select Report Header from the Report Designer main menu. The header band will be removed. 4 Select Report Footer from the Report Designer main menu. The footer band will be removed. 5 Click the report selection icon located at the intersection of the horizontal and vertical rulers. The report will be selected in the Object Inspector. 6...

Create a Table Data Source and Data Pipeline Component

1 Select the Data Access tab of the Delphi component palette. 2 Add a Table component to the form. 3 Configure the Table component DatabaseName Name TableName IndexFieldName DBDEMOS tblCustomer customer.db Company 4 Add a DataSource component to the form. 5 Configure the DataSource component 6 Select the RBuilder tab of the Delphi component palette. 7 Add a DBPipeline component dbi to the form. 8 Configure the DBPipeline component DataSourcedsCustomer NameplCustomer

Define the Data Fields for the JITPipeline

1 Double-click on the JITPipeline component to display the Field Editor. 2 Click the Add button to add a new field. 3 Use the Object Inspector to set the following properties for the field NOTE The JITPipeline enables ReportBuilder to access data as if it were stored in a database. The field lengths specified here are maximum lengths. 6 Select the form and add the following code to the OnCreate event (below the call to 'PipeDataTo-Grid') plCustomer.InitialIndex 1 7 Select File Save from the...

Create a New Application

2 Select File New Application from the Delphi menu. This will create a new project and a blank form. 3 Set the Form name to 'frmViaDataTree'. 4 Select File Save As from the Delphi menu and save the form under the name rbViaDT in the My RB Tutorials directory. 5 Select View Project Manager from the main menu. 6 Right-click over the project name in the Project Manager (usually Project1.exe) and select the Save menu option. 7 Save the project under the name rbDTProj in the My RB Tutorials...

Application Tutorials

Create a New Application Create a ListBox and Preview Button on the Main Add a Form to the Create an Ancestor Form Make the Tutorial Report Form a Descendant of TrbReportForm 309 Populate the List Box in the OnCreate Event of the Main Form 310 Code the LaunchReport Procedure in the Main Form Hook the LaunchReport Procedure to the ListBox and Preview Button 311 Create a Customized Print Preview Add the Customized Print Preview Form to your Building an End-User Reporting Application Create the...

Configure the Designer Component

1 Select the Designer component Jl_ on the form. 2 Expand the DataSettings property in the Object Inspector. 3 Set the DatabaseName property to DBDEMOS. The DatabaseName indicates the database that contains the data to be retrieved by the reports. In order to keep this tutorial simple, we have used the same database alias for the data dictionary and report data tables. This is not a requirement. You could store the data dictionary in local tables and build queries over a remote database. 4 Set...

Introduction

The Best Way to Learn ReportBuilder 6 A Quick Test Spin 7 Elements of the User Interface 10 Working with the Report Designer 12 Reporting Basics 16 Welcome to the ReportBuilder Developer's Guide. This guide is written by ReportBuilder engineers for Delphi developers. The concepts and practical elements of reporting with RB will be revealed throughout this book, and the tutorials will transform the abstract concepts into concrete, useful reports and applications. Report creation with...

Groups Dialog

The Groups dialog is accessible via the Report Groups menu option of the Report Designer. You can separate your report into different sections using groups. A number of options are available to control the behavior of each group. For example, you may want each group to start on a new page or to reprint the group header when the group continues on additional pages. Another powerful feature is the Keep group together option, which can be used to ensure that all of the information for a group fits...

Complete the Detail Band

1 Place a Line component in the upper left corner of the detail band. 2 Locate the Line Position drop-down list at the upper left of the Report Designer. 3 Select Left from this list. A vertical line will appear on left side of the line component. 5 Copy and paste the line component. 6 Select Right from the Line Position drop-down list. The vertical line will move to the right side of the line component. 7 Drag the new line to the right side of the detail band. Hold down the Ctrl key and use...

Add the Run Time Interface Components

1 Close the Report Designer by selecting File Close from the Report Designer main menu. You can also close the Report Designer by clicking the X button located on the upper right corner of the Window Title bar or by double-clicking on the R icon . located in the upper left corner of the Window Title bar. 2 Select the Standard tab of the Delphi component palette. 3 Add a Group Box component to the form. 4 Configure the Group Box component 5 Add two Radio Button components to the Group Box 6 Add...

Define the Relationship Between the Order and Items Table

1 Select the Item table component. 2 Set the MasterSource property to dsOrder. 3 Select the MasterFields property and press the button. This displays the Field Link Designer. 4 Click on the Available Indexes drop-down list and select ByOrderNo. 5 Select the OrderNo item in the Detail Fields list. 6 Select the OrderNo item in the Master Fields list. 7 Click the Add button. A new item (OrderNo OrderNo) will be added to the Joined Fields list. 8 Press the OK button to close the dialog. The...

Complete the Order Information Layout

1 Select the plEmployee DataPipeline in the Data Tree. 2 Drag the FirstName field into the title band, positioning the mouse to the immediate right of the Date label. 4 Align the top of the new DBText with the top of the Date DBText component. 5 Set the label Caption to Sales Rep. 6 Place a shape component in the left side of the title band. 7 Align the left edge of the shape with the Number label and stretch the width until the right edge is flush with the right edge of the Sales Rep label. 9...

Add the Table Data Source and Data Pipeline for the Items Detail Table

1 Add a Table component to the form. 2 Configure the Table component 3 Add a DataSource component to the form. 4 Configure the DataSource component 5 Select the RBuilder tab of the Delphi component palette. 6 Add a DBPipeline db component to the form. 7 Configure the DBPipeline component

Modify the Report Layout to Contain Columns

1 Select File Page Setup from the Report Designer main menu. 3 Click the Up Arrow button located to the right of the Columns edit box. This should modify the number of columns from 1 to 2. 5 Right-click over the line component at the top of the detail band and set the ParentWidth property to True. When using the Component popup menus, a checkmark next to a menu option indicates the property is set to True. Selecting the menu option toggles the property from Checked to Unchecked (i.e. True to...

Create Data Access Components for the Folder Table

1 Select the Data Access tab of the Delphi component palette. 2 Add a Table component to the form. 3 Configure the Table component 4 Add a DataSource component to the form. 5 Configure the DataSource component 6 Select the RBuilder tab of the Delphi component palette. 8 Configure the DBPipeline component NOTE The Visible property of a DataPipeline controls whether the data pipeline can be selected within the Report Designer and assigned to a report or detail band. Since all pipelines created in...

Review the Create Tables SQL script for the Report Explorer

This tutorial requires that you have InterBase installed and know how to use it. The concepts covered in this tutorial can be adapted to other SQL based databases. The SQL scripts used to create the InterBase tables can likewise be used as a starting point for creating scripts for other types of SQL databases. However, examples for a number of popular database products are included with ReportBuilder. These examples can be found in RBuilder Demos EndUser Databases. The Report Explorer is...

Populate the List Box in the OnCreate Event of the Main Form

1 Select View Project Manager from the Delphi main menu. 4 Double-click the OnCreate event. The event handler shell will be generated and the Code Editor will be displayed. 5 Add the following line of code to the event handler lbxReports.Items.AddObject('Creating a Report via the Report Wizard', 0> TObject(TfrmViaReportWizard)) This code stores a description of the report and the class type for the form containing the report in the list. The class type will be used to instantiate an instance...

Create the Join Data Dictionary Tables

Accept the Paradox 7 table setting. Enter the following fields in the dialog 2 Click the Save As button and locate the directory where your DBDEMOS alias is pointed (usually C Program Files Common Files Borland Shared Data) and save the table under the name rbJoin.

Group Total

Report group totals can be easily calculated by placing a DBCalc in the group footer band. The ResetGroup is automatically assigned when a DBCalc is placed in a group band. Thus, each time the group breaks, the group total will reset to 0. Using a DBCalc component to number the master and detail records

Report Tutorials

Create a Tutorial Create a New Create a Table, DataSource, and DataPipeline Create a Report and Connect it to the Data Invoke the Report Designer and Set the Paper Orientation 182 Set the Header Band Height to 1 inch Create Labels in the Header Band Use the Data Tree to Lay Out Customer Information Adjust the Add a TimeStamp Add Page Preview the Report at Creating a Report Via the Report Wizard Create a New Application Create a Table, DataSource, and DataPipeline Create a Report and Connect it...

Create the Stock Summary Sub Report

1 Place a second SubReport component in the detail band. 2 Position it so that the top is flush with the bottom of the Customer List subreport. This step is not necessary it just helps to create a clean layout. The print order of the subreports is not determined by their top to bottom order within the band. Print order is actually determined by the layering of the components Send to Back Bring to Front order . The report at the back is printed first the report at the front is printed last. You...

About RAP

The following paragraphs describe why we are so excited about RAP. The RAP language is identical to Object Pascal. If you know how to code Delphi event handlers, you know how to code RAP therefore, the learning curve for Delphi developers is minimal. RAP lets you work with objects and object properties. RAP provides full access to the report, bands, groups, report components, data pipelines, and any other objects you wish to pass along to the end user. New objects can be created. Both the...

Configure the Report

1 Click the Select Report icon at the upper left corner of the Report Designer workspace. 2 Set the PageLimit to 1 and the AutoStop property to False in the Object Inspector. This report is not connected to any data, so it has no basis on which to stop generating pages. In this situation, the AutoStop property defaults to True so that the report will print only one detail band. Because we want to fill a single page with detail bands, we turn AutoStop off and set the PageLimit to one. 3 Select...

Soft Code the Text File Name

1 Access the OnClick event for the Print button and change the event handler so that it looks like the code below. 2 Select Project Compile rbTTProj. Fix any compilation problems. 3 Select File Save from the Delphi main menu. Print the Report to File 2 Click the Print button. Notice that the Print to File option is selected. 3 Click OK to print to the file. 4 Close the form and return to the Delphi design environment. 5 Select File Open from the Delphi main menu and set the files of type to...

Invoke the Report Designer and Configure the Page Layout

1 Select the RBuilder tab of the Delphi component palette. 3 Double-click on the Report component to display the Report Designer. 4 Size and move the Report Designer window so that the Object Inspector is visible. 5 Select File Page Setup from the Report Designer main menu. 6 Select the Layout tab. Enter the following values Column Position 1 0.28 Column Position 2 2.34 Column Position 3 4.4 Column Position 4 6.46 7 Select the Margins tab. Enter the following values 8 Click the OK button to...

Add a Time Stamp

1 Return to the Design workspace. 2 Click the SystemVariable component icon on the Report Designer component palette. 3 Click on the far left side of the footer band. A System Variable component will be created. 4 Position the component at the top left corner of the footer band. 5 Locate the drop-down list in the upper left corner of the Report Designer. It should contain a list of variable types for the component. 6 Select the PrintDateTime item from this list. The current date and time should...

Simple End User Report Solution

We can create a simple end-user reporting solution using just a designer component and a report component. 1 Create Report and Designer components. Place a designer component and a report component on a form, then connect the report to the designer by assigning the Designer.Report property. Create data access components to supply data to the report. Here we have created TTable, Tdata-Source, and TDBPipeline components. The Table-Name of the TTable component has been set to 'customer.db' so that...

Create the Grand Total

1 Return to the Report Designer. 2 Place a DBCalc component at the bottom of the summary band. 3 Right-click over the component and access the Calculations menu option. 4 Select the Count function from the Calc Type drop-down list and click the OK button. 6 Click on the vrSellTotal variable, then Shift-click the DBCalc component. Font Name Font Size Font Style Font Color Text Alignment Width 7 Click on the Align Right icon of the Align or Space toolbar. 8 Select the Total label, then the DBCalc...

Query Designer Adding Search Criteria

You can use the Query Designer to add or remove search criteria from your query. Perform these steps in order to add search criteria 1 Click on the Search icon of the dataview to launch the Query Designer. 2 From the list of fields at the top of the search page, double-click on the field for which criteria needs to be entered. Query Designer Adding Search Criteria - cont. 3 Click on the field that has been added to the list of criteria at the bottom and select the operator. 5 Click on the SQL...

Add Page Numbers

1 Scroll right until the edge of the footer band is visible. 2 Click the SystemVariable component icon on the Report Designer component palette. 3 Click on the far right side of the footer band. A SystemVariable component will be created. 4 Use the drop-down list on the left side of the Report Designer to select the PageSetDesc variable type. Page 1 of 1 should be displayed in the component. 5 Position the component at the top right corner of the footer band. 6 Right-justify the component by...

Code the Before Generate Event of the Group Header Band

1 Click in the white space of the group header band. The band should be selected in the Object Inspector. 2 Click on the Events tab of the Object Inspector and double-click on the BeforeGenerate event. Add the code shown below to the event handler. This routine retrieves the value of the recommendation field into a local string variable. It then assigns a color based on the value of the field. The color is stored in a private variable of the form so that all of the report event handlers can use...

Report Builder Enterprise Edition Fundamentals

Preview DBPipeline TextPipeline DataDictionary Designer AllowDataSettingsChange DataSettings Icon RAPInterface RAPOptions ShowComponents TabsVisible A Simple End-User Report Designer FolderFieldNames ItemPipeline FieldPipeline TablePipeline Summary Dataview Query Wizard Create a Simple Query-Based Dataview 138 Query Designer Adding Search Create a Group Concatenate Edit SQL DataDictionary SessionType Database Product and SQL Data Basic Classes Implementation Dataview Templates Dataview Template...

Create Sub Report and Connect it to the Data

2 Right-click over the vertical line component located at the extreme left of the detail band. Select the StretchWithParent and ReprintOnOver-flow menu options. 3 Right-click over the vertical line component at the far right of the detail band. Select the Stretch-WithParent and ReprintOnOverflow menu options. The detail band will contain a child-type subreport that will stretch to print all of the items for the current order. By setting Stretch-WithParent to True, we are saying Whatever the...

Conditional Grand Total

To exclude certain values from a grand total, add a Variable component to the summary band. Then code the OnCalc event handler as Procedure TForm1.ppVariable2Calc Sender TObject var Value Variant var lcValue if lcValue gt 5000 then Value Value lcValue This event handler will accumulate the value of the variable only when the amount paid is greater than 5,000. The screen shot below shows the result. Notice that this report also has a conditional group total in the group footer band. Using a...

The Report Explorer

The Report Explorer component allows you to deploy a Windows Explorer interface that your end users can use to organize their reports. The Report Explorer handles all operations via data pipelines therefore, the folder structure and all of items within it can be saved to database tables. This interface presents a minimal learning curve, as most users are familiar with the operation of the Explorer. The Report Explorer user-interface is pictured below

Run the Application

1 Select the Win32 tab of the Delphi component palette. 3 Configure the StatusBar component 4 Add a Button component to the form. 5 Configure the Button component 6 Add the following code to the OnClick event handler of the button if not ppReportExplorer1.Execute then stbStatusBar.SimpleText First we set the SQLHourGlass property to False. We do not want the cursor to be displayed when using the Report Explorer to create folders and reports. Next, we called the Execute method to invoke the...

Lay Out the Group Header Band for the Sub Report

1 Place a shape component in the upper left corner of the group header band. 2 Configure the shape component 3 Hold down the Ctrl key and use the down arrow key to move the shape until the bottom is flush with the bottom of the band. Begin Laying Out the Items Information Components for the SubReport 1 Select View Toolbars Data Tree from the Report Designer menu. Position the Data Tree to the left of the Report Designer. 2 Click the Layout tab at the bottom of the Data Tree and configure the...

Complete the Layout for Sub Report

2 Right-click over the Orderno DBText component located on the far left side of the detail band. Set the ReprintOnOverFlow menu option to True. OverFlow occurs when the detail band runs out of page space on the current page and must complete printing on the next page. For this report we want to print the ItemNo followed by 'Continued ' at the top of the page when the orders for a given customer overflow onto an additional page. 3 Place a label in the detail band and configure it Caption Name...

Add a Color Coding Event Handler

1 Add the following variable to the private section of the form 2 Add the following code to the OnCreate event of the form 3 Add the following code to the OnDestroy event of the form procedure TfrmRegions.FormDestroy Sender Event handler for the OnCreate Event FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors FColors end...

Lay Out the Group Footer Band for the Sub Report

1 Select the shape component in the group header band. 2 Copy and paste the selection. Drag the new shape into the group footer band and position it at the upper left corner 3 Select the Item Total label in the group header band. 4 Copy and paste the selection. Drag the new label into the group footer band. 5 Set the label caption to Total. 6 Select the List Price label in the group header band, then Shift-click the Total label. Click the Right Align icon on the Align or Space toolbar. 7 Select...

Concatenate Fields

Delphi Report Builder

You can enter SQL expressions from the Calc tab of the Query Designer. The following query selects data from a table of employees. The table has a first name and last name field. Perform these steps in order to concatenate these two fields together using the Query Designer 1 Click the 'Calcs' icon to launch the Query Designer. 2 Double-click the 'First Name' field from the selection list at the top of the page. 'First Name' will be added to the list of calculations. 3 Select 'Expression' as the...

Look Ahead Total

ReportBuilder has the flexibility to operate as a one pass or two pass report engine. This example shows how to calculate group totals so that they can be displayed in the group header. 2 Place a DBCalc component in the group header band. 3 Right-click and set the LookAhead property to True. 4 Preview. The total prints before the detail. Using a DBCalc and a variable to display a group total at the beginning of a group

Calc Tab The End User View

The RAP user interface can be configured to meet the needs of your end users. There are three basic configurations available For casual end users, a simple Calculations dialog is accessible from the speedmenu of the new Tpp-Variable component. This dialog provides a place for calculations to be entered and returned via a single Result parameter. The calculation result is then displayed in the variable when the report prints. In order to configure the user interface to provide this level of...

Create the Customer List Sub Report

1 Place a SubReport component in the detail band. 2 Position the subreport so that it is flush with the top of the detail band. 3 Right-click over the subreport and select the Section menu option. When a subreport is created, it defaults to a PrintBehavior of pbChild. Child subreports print within the context of the parent band, much like a stretching memo. Section subreports generate entire pages, creating a whole section within the parent report. 4 Name the subreport srCustomerList. Whenever...

The Text Pipeline Component

Reports can be printed directly from text files without using a database product. This functionality is provided via the TextPipeline component. The following formats are supported Custom-delimited where you specify the delimiter The TextPipeline component is essentially a simple data retrieval engine that enables you to access data in text files in the same manner as data stored in a database table. You can even define master detail relationships between data in two text files. The...

Code the Event Handlers

1 In the private section of the form unit, add the following declaration 2 Add an event handler for the Form OnCreate event Event handler for the Form OnCreate event procedure TfrmViaReportWizard.FormCreate Sender TObject begin get the path name for this application FPathName ExtractFilePath ParamStr 0 set the initial report template file name rbCustomerList.Template.FileName FPathName 3 Add event handlers for each Button's OnClick event Event handler for the Buttons' OnClick event load the...

Conditional Group Total

Delphi Report Builder

When you need to exclude certain values from a group total, add a Variable component to the group footer band. Access the Timing dialog and set the 'Calculate On' to DataPipeline Traversal, select the appropriate Data Pipeline, then set 'Reset On' to Group Start and select the appropriate group. Code the OnCalc event handler as This event handler will accumulate the value of the variable only when the amount paid is greater than 5,000. procedure TForm1.ppVariable1Calc Sender TObject var Value...

Dataview Template The End User View

1 When dataview templates are registered with DADE, an additional tab is added to the New Items dialog. The figure below shows what we would see if we accessed the File New menu option within the data workspace Dataview Template The End User View - cont. 2 Here we can see that four different dataview templates have been registered. After double-clicking on the 'Order' template, the following screen would appear 3 This is a custom dialog created by the developer of the Order dataview template....

Adjust the DBText Components

1 Right-click over the 'Length_In' DBText component and set the DisplayFormat to ,0 - ,0 the first DisplayFormat in the list . 2 Select all of the components in this region. 3 Set the AutoSize property to True in the Object Inspector. 4 Right-click over the white space of the Region and select the ShiftRelativeTo menu option. 5 Select the rgMemo region from the drop-down list and then click the OK button. We set the Stretch property of the DBMemo component to True. That means that each time the...

Report Builder Fundamentals

Data Data Process Report Layout Report Output DBPipeline TextPipeline JITPipeline Archive Label Shape CheckBox DBCheckBox Region StopPosition for subreports ReprintOnOverFlow One Memo in the Detail One Memo with a Shape Background One Memo with Label Two Stacked Memos in the Detail Two Side-by-Side Memos with Labels Child SubReports in Fixed Positions One Memo with Two Side-by-Side Memos Single Master Dataset with Single Detail Dataset Master Dataset with Nested Detail Datasets Master Dataset...

Calc Tab Views

In order to configure the user interface to provide this level of functionality, set the RAPInterface riNotebookTab property to True and set all of the RAPOptions to True. When the Report Designer is displayed, the Calc tab will be visible. If you right-click on the treeview on the left, a speed menu that shows the different views of calculations available will be displayed This view shows the variables in each band of the report. ReportBuilder Enterprise Edition Fundamentals - Code This view...

Archiving a Report

You can print a report directly to archive with the following code ppReport1.ShowPrintDialog False ppReport1.DeviceType dtArchive ppReport1.ArchiveFileName 'c test.raf' ppReport1.Print In this code, the Print dialog is hidden the device type is set to 'Archive' the archive file name is specified, and the report output is generated. Archive files are usually given the file extension 'raf', which stands for Report Archive File. B Allow end users to print to archive. In order to give the end user...

Create the Field Data Dictionary Table

1 Select Tools Database Desktop from the Delphi main menu. 2 Select File Working Directory from the Database Desktop main menu. 3 Click the Browse button and select the following directory C Program Files Common Files Borland Shared Data 4 Click the OK button to close the dialog. 6 The Create Table dialog will be displayed. It should default to a table type of 'Paradox 7'. Click OK to continue the table creation process. 7 Enter the following fields in the dialog NOTE The TableName and...

Lay Out the Group Header Band

1 Place a label in the left side of the group header band. 2 In the Object Inspector, set the Name of the component to rlRecommendation. 4 Place a line component near the bottom of the group header band. 5 Right-click over the line component and select the ParentWidth option. 6 Locate the Line type drop-down list at the upper left corner of the Report Designer. 7 Select 'Bottom' from this list. This causes the line to be drawn at the bottom of the rectangular bounding shape. 8 Click on the Line...

Create a Report and Connect it to the Data

1 Add a Report component U to the form. 3 Double-click on the Report component to display the Report Designer. 4 Position the Report Designer so that the Object Inspector is visible. 5 Place a subreport Je component from the Advanced toolbar in the detail band. When you add the subreport, two tabs will be displayed at the bottom of the workspace Main and SubReport1. There is a separate workspace for the main report and for each subreport. You can access the workspace for any given report by...

Compile and Run the Application

1 Select the Win32 tab of the Delphi component palette. 4 Add a Button component to the form. 6 Add the following code to the OnClick event of the button if not ppReportExplorer1.Execute then stbStatusBar.SimpleText This code calls the Execute method to invoke the Report Explorer. If we have not configured one of the Report Explorer properties correctly, the form will not be displayed, False will be returned, and the reason for the failure will be displayed in our status bar. 7 Select Project...

Create a New Report Explorer Form

1 Select File Open menu from the Delphi main menu. 2 Locate the ppExpFrm.pas unit in the RBuilder Source directory. 4 Change the form name from ppReportExplorer-Form to rbReportExplorerForm. 5 Select the panel at the top of the form named tbrExplorer and use the Object Inspector to set the color to clMaroon. 6 Scroll to the bottom of the form unit and inspect the initialization section. It should contain the following 0 gt TrbReportExplorerForm end. The Delphi Code Editor automatically changed...

Delphi Report Builder For Grouping

Query Designer Selection

The SQL 'GROUP BY' clause allows you to eliminate rows in your query where the field values repeat. For example, let's assume we have a database table that contains order records. Each order record has the customer number and the amount paid. If we viewed the data in this table, we would see that the value in the customer number field repeats where there are multiple orders for a customer. We can use SQL to select data from the orders table and calculate the total amount paid for each customer....

Code the Launch Report Procedure in the Main Form

1 Add the LaunchReport procedure declaration to the private section of the main form. The code should look like this 2 Add the following units to the uses clause at the top of the unit 2 Double-click on rbMain to open this form. 3 Select the Events tab of the Object Inspector. 3 Add the LaunchReport procedure to the implementation section. The code should look like the code below. 4 Select File Save from the Delphi main menu. This routine retrieves the class type from the list box, instantiates...

Report Builder Newsgroups

The following list of newsgroups are accessible from the Support section of our website tech tips posted by digital metaphors general report building run-time Pascal development environment using free-form subreports developing end-user reporting solutions report data access database, textfiles, stringlists report output printer, screen, file, archive custom report components, datapipelines, and beta program for upcoming releases Take advantage of these newsgroups they afford you the...

Allow the end user to print to a report emulation text file

The following code would give the end user the option of printing to a report emulation text file when the print method is called ppReport1.AllowPrintToFile True ppReport1.TextFileName 'c test.txt' ppReport1.DeviceType dtPrinter ppReport1.ShowPrintDialog True ppReport1.Print In order to get the free-form text of the report output to map correctly to the character grid of a text file, it is sometimes necessary to tweak the positions of the components within the report layout. An example of a...

Preview the Report at Runtime

1 Close the Report Designer window. 2 Select the Standard tab of the Delphi component palette. 3 Add a Button component to the form. 4 Configure the Button component 5 Add the following code to the OnClick event handler of the button 6 Select File Save from the Delphi main menu. 8 Click on the Preview button. The DeviceType property of the report component defaults to Screen thus, the report automatically displays the Print Preview form when the Print method is called. The Preview form should...

Add Additional Values to the Crosstab

1 Drag the Amount Paid field over the new value cell and release it. 2 Select the second Sum of Amount Paid value. 3 Locate the drop-down list box on the toolbar. 4 Select Average from the drop-down list. 5 Once again, drag the Amount Paid field over the new value cell and release it. 6 Select the second Sum of Amount Paid the one below the average . 7 Select Count from the drop-down list. 9 Select File Save from the Delphi main menu. 10 Preview. The crosstab includes new values. Advance to the...

Design the Crosstab

1 Return to the design workspace, right-click over the crosstab, and select Configure. 2 Drag the Amount Paid field over the new value cell. When the indicators appear, release the mouse button. NOTE The number 1000 represents the format of the calculated value. The Grand Total indicates that the last row of the crosstab will show the total Amount Paid for all months.

Set the Report to Two Pass Mode

1 Select the System Variable component on the far right of the footer band. 2 Use the drop-down list control in the far left corner of the Report Designer to change the variable type from PageNoDesc to PageSetDesc. 3 Click the Select Report icon, which appears at upper left corner of the Report Designer where the horizontal and vertical rulers meet. This will select the report object in the Object Inspector. 4 Locate the PassSetting property of the Report in the Object Inspector. 5 Make sure it...

Create a Customized Print Preview Form

1 Close the application and return to the Delphi development environment. 2 Select File Open from the Delphi main menu. Locate the ppPrvDlg unit in the RBuilder Source directory. Open this unit. 3 In the Object Inspector, change the form name from ppPrintPreview to rbPrintPreview. You may have to use the drop-down list box at the top of the Object Inspector to find the ppPrintPreview form . 4 Save the form in the My RB Tutorials directory under the name rbPrvDlg. 5 Select the panel at the top...

Create a Query Data Source and Data Pipeline Component

1 Select the Data Access tab of the Delphi component palette. 2 Add a Query component to the form. 3 Configure the Query component SELECTAmountPaid, State, EXTRACT MONTH FROM SaleDate AS SaleMonth FROM Customer, Orders WHERE Orders.CustNo Customer.CustNo 4 Double-click on the Active property in the Object Inspector to set it to True. 5 Add a DataSource component to the form. 6 Configure the DataSource component 5 Place a crosstab component j from the 7 Select the RBuilder tab of the Delphi...

Code the Calculations for the Totals

1 Select the vrItemTotal variable in the detail band. 2 Select the Events tab of the Object Inspector. 3 Double-click on the OnCalc event. An event handler shell will be generated in your Delphi form. 4 Add the following code to this event handler Value plItem 'Qty, plPart ,ListPrice' This event handler retrieves the quantity and list price of the item and returns the total amount via the Value parameter. The result will become the value of the variable component. The OnCalc event will fire...

Delphi Reportbuilder Dbtext Color

The Edit toolbar allows you to set the most important property for a given component. For example, when a Label component is selected, an edit box appears that allows you to set the Caption. When a DBText component is selected, two drop-down lists appear that allow you to set the Data Pipeline and the DataField. This toolbar appears to the right of the Edit toolbar. It's used to configure the font of textual components and to control component layering via the Bring to Front and Send to Back...

Create a Group on the OrderNo Field

1 Select Report Groups from the Report Designer main menu. The Groups dialog will be displayed. 2 Select plItem.OrderNo from the drop-down list at the top of the dialog and click the Add button. A new entry entitled Group 0 plItem.OrderNo will be added to the list. 3 Click the OK button. You should see two new bands one above and one below the detail band. These bands have no height thus, no white space appears above the dividers. We created a group on the OrderNo field because this is the...

Controlling Data Traversal

The second purpose of the data pipeline is to control data traversal. Data traversal is the act of moving from the first record of the data to the last record. When a report is printed, the report engine traverses the data by completing the following steps 3 Begins printing the page and then gives the detail band the opportunity to print. 5 Gives the detail band the opportunity to print. 6 Continues steps 4 and 5 until there is no more page space. 8 Continues steps 4 through 7 until all records...

Digital-metaphors.public News

Introduction 23 The Delphi Components 25 Report Components 26 Smart Layouts 29 SubReports 34 Form Emulation 37 ReportBuilder is a development environment that can be used to construct reports, report components, and reporting applications. Because reporting encompasses a very wide range of requirements, it is often difficult to put a limit on what should be expected of a reporting tool. The designers of ReportBuilder reduced this broad set of requirements down to the following equation Report...

Create the Withholding DBText Components

1 Select the Wages, SSWages, and MedicareW-ages DBText components. 2 Copy and paste the selection. 3 Drag the selection to the right, positioning it over '2 Federal income tax withheld' area of the image. 4 Set the width of the components to 1.6042 in the Object Inspector. 5 Hold down the Ctrl key and use the arrow keys to position the components 6 Set AutoSize to True in the Object Inspector. All three DBText components should be autosized. 7 Click on the image to deselect the components. 8...

Add the Customized Print Preview Form to your Project

1 Select the View Project Manager option from the Delphi main menu. 2 Right-click over rbMainProj and select the Add menu option. 3 Locate rbPrvDlg.pas in the My RB Tutorials directory and add it to the project. 4 Right-click over rbMainProj and select the Options menu item. 5 Select the Forms tab and move the rbPrintPre-view form from the Auto-create list to the Available forms list. 6 Select Project Compile rbMainProj. Fix any compilation problems. 7 Select File Save from the Delphi main...

Using the Archive Reader

Once archive files have been created, they can be read by the ArchiveReader component. The ArchiveReader component has a set of capabilities similar to the Report component. In fact, these two components descend from the same common ancestor. You can print the contents of an archive file to a standard Print Preview window with the following code ppArchiveReader1.ArchiveFileName 'c test.raf' ppArchiveReader1.DeviceType dtScreen ppArchiveReader .Print

Generation

Report output is primarily generated via a call to the Print method of the report object. The following code would cause the Print Preview form to be displayed and the first page of the report to be presented in this form ppReport1.DeviceType dtScreen ppReport1.Print This code would cause the Print dialog to be displayed. The report would then be sent to the printer ppReport1.DeviceType ppReport1.Print As you can see, it is quite easy to generate a report using ReportBuilder. In order to use...

Assign Event Handlers to the OnCalc Events of the Variable Components

1 Select the vrBuyTotal variable. 2 Click on the Events tab of the Object Inspector. 3 Double-click on the OnCalc event. An event handler shell will be generated in your Delphi form. 4 Assign the following code to this event handler 'BUY' then 5 Assign the following code to the OnCalc event of the vrHold variable 'HOLD' then 6 Assign the following code to the OnCalc event of the vrSell variable 'SELL' then All three of these event handlers check the field value to make sure it corresponds to...

Align the Recommendation Data Components

1 Select the RCMNDATION label and then the line component. 2 Click on the Align Left icon N of the Align or Space toolbar. 3 Select the Vital Stats label and then the Recommendation label. 4 Click on the Align Top icon ngt of the Align or Space toolbar. 5 Select the line behind the Vital Stats label, then the line behind the Recommendation label. 6 Click the Align Top icon nQi of the Align or Space toolbar. 7 Select the Recommendation line and label. 8 Click on the Align Middle icon of the...

Coding a Report

A report layout is composed of a set of components. Like other standard Delphi components, the components that make up a report layout have a run-time interface. That is, they can be created and configured using Object Pascal code. This capability can be used to create entire reports dynamically. Take these steps to create a report dynamically 1 Create data access components. These are the same steps you would follow to create a report using the Delphi IDE and the Report-Builder Report...

Table Pipeline

The name of the data pipeline that has access to the table aliases. The data module for the database tables underlying the data dictionary is shown below. The TableName is the key field of the table table. The TableName and FieldName are the key fields of the field table. The Selectable field determines whether the field can be selected within the Query Wizard and Query Designer. The Searchable field determines whether the field can be used in search criteria. The Sortable field determines...

The Default Language

When ReportBuilder is installed, the installation program allows you to specify a default language and any additional languages you wish to use. The installation will then install the appropriate files onto your system. The Report.Language property defaults to the lgDefault language type. This type correlates to the language resource files located in the RBuilder Lib directory and the language DLLs located in the Windows System directory the DLLs with the .dft extension . The .res files are...

Complete the Items Information Layout

1 Select the Qty field of the plItem data pipeline in the Data Tree. 2 Drag the selection to the immediate right of the Description label. 4 Right justify the components. 5 Set the label caption to Quantity. 6 Align the top of the new DBText with the top of the existing DBText components. 7 Select the List Price field of the plPart data pipeline. 8 Drag the selection to the immediate right of the Quantity label. 10 Right justify the components. 11 Set the label caption to List Price. 12 Set the...

Custom Translations

You can modify the .rc source files in the custom language folder in order to create your own custom translation. The rc files are named the same as their resource file counterparts rbPrint.rc Strings used by ReportBuilder rbIDE.rc Strings used by the Report rbDADE Strings used by the Data Access Development Environment the 'Data' tab You can create a custom translation by completing the following steps 1 Run the Language Translation application. Create new rc files using the ReportBuilder...

Set Page Numbers

1 Locate the horizontal scroll bar at the bottom of the Report Designer. 2 Scroll right until the right edge of the footer band is visible. 3 Click the SystemVariable component icon on the Report Designer component palette. 4 Click on the far right side of the footer band. A SystemVariable component should be created. 5 Use the drop-down list on the left-hand side of the Report Designer to select the PageSetDesc variable type. Page 1 of 1 should be displayed in the component. 6 Right-click over...

Create a Memo Region

1 Place a region immediately below the image region. Notice that the region has a one pixel-wide black border. You can turn this border off by setting the Line Color to 'No Line' in the Report Designer or by setting the Pen.Style to psClear in the Object Inspector. 3 Select the Notes field in the Data Tree field list. 4 Drag the Notes field from the Data Tree into the white space of the memo region. 5 Configure the DBMemo component 6 Select File Save from the Delphi main menu. NOTE By setting...

Preview the Report at Run Time

2 Select the Standard tab of the Delphi component palette. 3 Add a Button component to the form. 4 Configure the Button component 5 Add the following code to the OnClick event handler of the button 6 Select File Save from the Delphi main menu. 11 Drag the footer band divider up until it meets the bottom of the System Variable components. 7 Run the Project. Click the Preview button. The report should look like this

Data Access

In Delphi, data access via the BDE can be accomplished using a TTable or TQuery component. A TDatasource component is then connected to the table or query. A data-aware component can then be connected to the datasource. The following screen-shot shows a field value being retrieved into a data-aware memo component. ReportBuilder augments this data access model by adding another component the data pipeline. There are several different types of data pipelines, but for purposes of accessing data...

Create Labels for the Header Band

1 Place six labels in the header band and position them from left to right. Set the label captions as follows 3 Hold down the Shift key and click on the Contact label. 4 Repeat this procedure until all six labels are selected. Font Name Font Size Font Style Font Color 6 Leave these labels at their current positions we will align them later.

Assign the Before Generate Event Handler of the Detail Band

1 Click in the white space of the detail band. 2 Click on the Events tab of the Object Inspector. 3 Double-click on the BeforeGenerate event. An event handler shell will be generated in your Delphi form. This routine sets the color of the stock symbol and the recommendation field to the color as defined in the BeforeGenerate event of the group header band. 5 Select File Save from the Delphi main menu. 6 Select Project Compile rbSTProj from the Delphi main menu. Fix any problems. 8 Preview the...

Lay Out the Detail Band

Delphi Detailband

1 Click the DBText component icon A on the Report Designer component palette. 2 Click in the detail band. A DBText component will be created. 3 Locate the two drop-down lists at the upper left corner of the Report Designer. The list on the left contains the data pipelines. It should default to the Customer data pipeline, since this is the data pipeline for the report. The list on the right contains a list of fields for the currently selected data pipeline. 4 Select the Company field from the...

Count Master Detail

A master detail report usually contains a group based on the key field in the master table. This allows the fields from the master table to be printed in the group header, as opposed to repeating in the detail band. In order to count the master records, place a DBCalc in the group header band and set the CalcType to count. Then access the Calculations dialog and clear the Reset Group setting. The ResetGroup is automatically assigned when a DBCalc is placed in a group band. When set, this...

Loading and Saving Reports

Set the Report.Template.SaveTo property to stDa-tabase. Select the File Save As menu option from within the Report Designer. A special Save dialog will be displayed, showing all reports in the given database table. You can name the report and then save it to the table. Select the File Save As menu option from within the Report Designer. Once a report is saved, you can load it by accessing the File Open dialog. The following code saves a report in the 'test.rtm' file ppReport1.Template.FileName...

Overview

'Report Template' refers to the binary image created when a report layout is saved to a file or to a database BLOB field. You can use report templates to free your report definitions from the confines of the executable in which they are being utilized. Therefore, if you need to make modifications to a report, you can do so without recompiling and redeploying your entire application. Simply send the new report layout file or database table containing the report layouts to your users. If you save...

Make the Tutorial Report Form a Descendant of Trb ReportForm

1 Select View Project Manager from the Delphi main menu. 2 Double-click on the rbViaWiz unit to open the form. 3 Access the rbViaWiz unit and maximize the Code Editor. 4 Add rbClass to the uses clause at the top of the unit. The code should look like this Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ppBands, ppCtrls, ppPrnabl, ppClass, ppDB, ppProd, ppReport, ppComm, ppCache, ppDBPipe, ppDBBDE, Db, DBTables, ppVar, rbClass We must add the rbClass unit to...

Filebased Templates

You can load and save report layouts to files using the Report Designer. You can also load and save layouts programmatically. Set the Report.Template.SaveTo property to stFile this is the default value . Select the File Save As menu option from within the Report Designer. The standard Windows file save dialog will be displayed, enabling you to save the report template to a .rtm file. Select the File Open menu option from within the Report Designer. The standard Window file open dialog will be...

Create a Group on the Category Field

1 Select Report Groups from the main menu. 2 Select the 'plBiolife.Category' field from the drop-down list at the top of the dialog. 3 Click the Add button. A new group will be added to the list. 4 Click the Start New Column checkbox in the 'On Group Change' section of the dialog. 5 This option forces a new column each time the group changes, which allows each of the records from the Biolife table to appear in a separate column. 6 Click OK to close the Groups dialog. You may notice that the...

Print Preview

Delphi Form Rapor Bask

The most high-profile and oft-used form of report output is contained in the Print Preview form. The Print Preview form is launched automatically when the Print method of the report component is called and the DeviceType property has been set to 'Screen' . The Print Preview form is pictured below. While the Print Preview form provided with ReportBuilder looks and performs like a truly professional user-interface should, you may want to customize it to emulate the look and feel of the rest of...