Search the Wiki

Viewing 351 to 385 of 409 items

PrintOnFirstPage for One Page Reports

TECH TIP: Using PrintOnFirstPage for One Page Reports Question: “I have a Footer that I do not want to print on the first page of my report, unless the report is only one page.” Solution: Both the Headerband and FooterBand have boolean properties called PrintOnFirstPage and PrintOnLastPage that can be used to control whether the  Full Article…

0

How To…Suppress Other Report Objects with Repeated DBText

Question “I have a DBText set to Suppress Repeated Values.  Is it also possible to suppress other report objects located in the detail band if the DBText is a repeated value?” Solution Use the DetailBand.BeforePrint event to determine whether the current record value is repeated, then toggle the visibility of the other components in the  Full Article…

0

How To…Skip Printing a Defined Number of Labels

Question “How do I start printing on the label of my choice when printing to a label sheet such as Avery?” Solution Use the DetailBand.BeforePrint event to keep track of the label that is being printed.  Then toggle the visibility of the components in the detail band based on which labels you would like to  Full Article…

0

How To…Create Report Fields in Code

Question “How do I dynamically create a report in code based on the fields in a datapipeline?” Solution Yes, this is a matter of simply looping through all the fields in the datapipeline(s) and dynamically creating labels/dbTexts for each field in code. Download: DynamicFields.zip Sample Delphi code: procedure TForm1.CreateText; var liIndex: Integer; liNumFields: Integer; lLabel:  Full Article…

0

How To…Create a Table of Contents

Question “How do I create a table of contents sorted by page at the beginning of my report?” Solution Use a group to separate out each topic in the table of contents.  During the first pass of the report, keep track of the current page inside the OnGroupBreak event for each group, then build the  Full Article…

0

How To…Create a Spread Sheet Style Report

Question “My report columns will not all fit on one page.  How do I extend them to the next page similar to a spread sheet?” Solution This can be done using multiple subreports connected to a single dataset.  Each subreport will contain different columns of data, the second and so on containing the overflow columns.   Full Article…

0

Create SubReport in Code

TECH TIP: Creating a SubReport in Code A subreport is comprised of two objects: SubReport Control The subreport control is added to a band of the ‘parent’ report. It has properties such as ShiftRelativeTo, PrintBehavior, etc. In the Report Designer, the subreport is drawn as a rectangle. ChildReport The child report is a descendant of CustomReport and has most of  Full Article…

0

Create Reports in Code

A ReportBuilder report is composed of a set of components. Like other standard Delphi components, the components which make up the report layout have a run-time interface. That is they can be created and configured using Object Pascal code. A complete example of creating a report entirely in code is contained in the Developers Guide.  Full Article…

0

Create Group in Code

TECH TIP: Create a Group in Code Question: “How can I dynamically create a report group at run-time?” Example code: uses ppClass, ppGroup, ppClasUt; function AddGroupToReport(aBreakName: String; aDataPipeline: TppDataPipeline; aReport: TppCustomReport); var lGroup: TppGroup; lGroupBand: TppGroupBand; begin {add group to report} lGroup := TppGroup(ppComponentCreate(aReport, TppGroup)); lGroup.Report := aReport; lGroup.BreakName := aBreakName; lGroup.DataPipeline := aDataPipeline; {add group  Full Article…

0

Calculating Dynamic Height of Detail Band

TECH TIP: Calculation Dynamic Height of Detail Band Sometimes you need to know the stretched height of a dynamically sized detail band after it has printer to perform further logic. This can be done by keeping track of where the report engine currently is on the page and where it was right before that. For example:  Full Article…

0

Calc Object Widths

TECH TIP: Calculating the Widths of Components at Run-Time The example below shows how to calculate the widths of report components and position them horizontally. This example procedure accepts a list of CustomText descendents and positions them flush left, one after the other.  The Left position of the first component is used as the starting  Full Article…

0

How To…Vertically Center Memo Text

Question “How can I vertically center text in a memo?” Solution Report output consists of a collection of Page.DrawCommands[]. Each time the Memo, generates, it creates a DrawCommand that describes the location and content to be rendered. We can use the Memo.OnDrawCommandCreate event to modify the DrawCommand. We can vetically center the wrapped text by inserting some empty  Full Article…

0

How To..Clickable DrawCommand with Custom Info

Question “How can I associate custom info with a hot-clickable component on my report?” Solution This example creates a TmyCustomInfo class that stores the CustNo and Country for a customer. The DBText OnDrawCommandCreate event is used to associate an instance of TMyCustInfo with each DrawCommand generated for the page. The DBText OnDrawCommandClick event shows how to access  Full Article…

0

How To…Unique Caption for Each Copy

Question “How do I display a unique caption for each copy of my report?” Solution ReportBuilder 11 introduced two copy related options to the System Variable component. Placing this component on your report and setting it to CopyNo or CopyNoDesc will display the copy number on each separate copy of the report. If more customization  Full Article…

0

How To…Refresh the Report After a Drawcommand Click

Question “How can I refresh/redraw the report after I click a “hot” component on my report?” Solution Inside the OnDrawCommandClick event of a report component, reset the report and report engine.  Then set the DrawCommand.RedrawPage property to True. This is very similar to the way the AutoSearch feature functions and can also be done with  Full Article…

0

How To…Manually Add a Watermark to a Page

Question “How can I add a watermark to a page in code without using the PageStyle band?” Solution Use the Report.OnEndPage event to create the drawcommands needed and manually add them to the page. Note: If you would like the watermark to appear behind the rest of the report components, create a Page Style and  Full Article…

0

How To…Format Text With Ellipse

Question “How can I append a ‘…’ to the end of text that is too wide to fit the bounds of a control?” Solution ReportBuilder 12 introduced the TppCustomText.Ellipsis property to automatically truncate text too wide to fit in a given area.  Below is an example of performing this task for versions earlier than RB  Full Article…

0

How To…Draw a Line After Last Detail

Question “How can I draw a horizontal line after the last detail band on each page?” Solution The solution is to use the DetailBand AfterPrint event to track the page position and then use the Report EndPage event to add a DrawComamnd to the Page.   Download:  LastDynamicDetailLine.zip Sample Delphi code: uses ppTypes, ppUtils, ppDrwCmd;  Full Article…

0

How To…AutoSize Font to One Page

Question “How can I shrink the font to force the report to produce a single page?” Solution This example contains a pre-processing step that generates the report pages to a dummy output device. If more than one page is produced, then the font size is adjusted. Following the pre-processing step, Report.Print is called to generate the report to  Full Article…

0

How To… Highlight Clicked Detail Bands

Question “How can I highlight every clicked detail band in the preview?” Solution This example shows how to change the color of a shape inside the detail band if the shape is clicked. Begin by assigning the detail band count to the Tag property of each shape drawcommand inside the OnDrawCommandCreate event. Then using a  Full Article…

0

How To…Fill a Page With Lines

Question “How can I fill the remaining space of a page with lines after the last detail has printed?” Solution Use a group to keep track of the position of the last detail band on a page.  The GroupFooterBand.AfterPrint event can be used to mark the position. The Report.OnEndPage event can then be used to  Full Article…

0

Event Tracker

Question:  “How can I understand when the various report events occur?” Answer:  Check out Demos 141 – 148 in the main reports demo app. These ‘event tracker’ demos show visually the sequence of various events. Page back and forth in the previewer to see what happens from page to page. You can easily create additional Event  Full Article…

0

SummaryCalc OnGroup Totals

TECH TIP: Calculating a Summary based on Group Totals Question: “I am using a Variable in the Group Footer to conditionally calculate totals for each group. I want to add a second Variable to the Summary that accumulates the results calculated for each group.” The following example uses two Variable components: vCustomerTotal and vCustomerSummary. The variable  Full Article…

0

Overview

TECH TIP: Performing Calculations Calculations can be done either on the data access side or within ReportBuilder. When designing reports there are always decisions to be made as to how much processing to do on the data side versus the report side. Usually doing more on one side can greatly simplify the other. So it  Full Article…

0

How To…Use a Look Ahead Value in a Calculation

Question “How do I make a calculation based on a total (such as a percentage) inside a report using a look ahead value?” Solution Retrieve the look ahead value using the DBCalc.GetLookAheadValue routine and convert it to a numerical type.  Then use this value in a new calculation elsewhere in the report. Download: CalcUsingLookAheadValue.zip CalcUsingLookAheadValuesRAP.zip Sample  Full Article…

0

How To…Show a Total in the Last Detail

Question “How can I show the sum of the previous details in the last detail band of a group, rather than using the group footer or footer band?” Solution This can be done by making the calculation in a TppVariable, then manually adding a DrawCommand to the page aligned with the last detail band of  Full Article…

0

How To…Keep a Running Total in the Header

Question “How do I keep a running total of the previous page(s) in the header band of the current page being viewed?” Solution Place a TppVariable inside the footer band of the report to keep track of the running total until that point.  Then assign that value to a TppVariable located inside the header band  Full Article…

0

How To…Display Subreport Totals in the Main Report

Question “How do I display totals calculated inside a subreport in my main report?” Solution Delphi: Update the main report variables directly inside the OnCalc event of a variable inside your subreport. RAP: Declare a global TppVariable from the Module view inside the code workspace (RAP). Set the global variable equal to a TppVariable in  Full Article…

0

How To…Count Distinct Records

Question “How do I count only the distinct records in my dataset using ReportBuilder?” Solution Keep track of the distinct records using a TStringList object. Download: CountDistinct.zip Sample Delphi code: procedure TForm1.FormCreate(Sender: TObject); begin FDistincts := TStringList.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin FDistincts.Free; end; procedure TForm1.ppReport1StartFirstPass(Sender: TObject); begin FDistincts.Clear; end; procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject); var liIndex:  Full Article…

0

How To…Calculate the Current Print Position

Question “How do I calculate the current position of a component after it has been generated to a report?” Solution Use the OnDrawCommandCreate event of the component to get the current position on the page, then use the conversion utility functions in ppUtils.pas to convert the value into report units. Download: CalcPrintPosition.zip Sample Delphi code:  Full Article…

0

How To…Calc a Dynamic Detail Height

Question “How do I calculate the height of each dynamic detail band’s height as the report is generating?” Solution Use the DetailBand.BeforeGenerate to find the top of each band and the DetailBand.AfterPrint event to find the bottom and calculate the height.  Do this during the first pass of the report to find each height before  Full Article…

0

TIBTransaction IdleTimer

TECH TIP: IdleTimer property on TIBTransaction When using a TIBDatabase and a TIBQuery you must also use a TIBTransaction for writing through to the database. There is a known issue if the IdleTimer property of the TIBTransaction object is set to some positive value. When printed, the report will get stuck on page 0 and  Full Article…

0

Migrating Master-Detail from RB 5

Starting with RB 5.5, the data traversal logic and report engine have been enhanced to support the new DADE linking features and to improve the ability of subreports to handle detail data. In the past the subreport did NOT properly honor the detail datapipeline SkipWhenNoRecords property. Now that this deficiency has been fixed it is  Full Article…

0

Data Access Errors

TECH TIP:  Troubleshooting DataAccess Errors Do not filter the dataset of modify it any way once the report.Print command is issued. If you need to do master/detail and cannot use linked datasets, then use the master DataPipeline.OnRecordPositionChange event to filter the detail dataset. The reports and datapipelines use dataset bookmarking. Make sure the dataset can  Full Article…

0

BLOB Errors in Old BDE

There are two BDE configuration settings that control how Blobs are handled. BlobsToCache Specifies how the BDE caches blobs when a dataset is traversed. If the value is set too low, this will result in an ‘Invalid Blob Handle’ error. Set BlobsToCache to -1 to enables an unlimited number of blobs to be cached. MaxBlobSize  Full Article…

0