LESSON 9 - Working with the DataReport Designer

5
WORKING WITH THE DATAREPORT DESIGNER 9 Visual Basic 6 is the first version that includes a report writer completely integrated in the IDE. Before using the DataReport designer, you must make it accessible from the IDE, which you do by issuing the Components command from the Project menu, switching to the Designer tab, and ticking the Data Report check box. Alternatively, you can create a new Data Project and let Visual Basic create an instance of the DataReport designer for you. The DataReport designer works in bound mode only, in the sense that it's able to automatically retrieve the data to be sent to the printer or simply displayed in the preview window. It can export a report to a text file or an HTML file and also supports custom format layouts. The DataReport designer comes with a set of custom controls that you can drop on its surface in the same way as you do with forms and other designers. These controls include lines, shapes, images, and also function fields, which you can use to create summary fields in your reports. Another intriguing feature of this designer is its ability to print in asynchronous mode, which lets the user perform other tasks while the printing proceeds. Information and Communication Technology Department Palompon Institute of Technology 75 Working with the DataReport Designer

Transcript of LESSON 9 - Working with the DataReport Designer

Page 1: LESSON 9 - Working with the DataReport Designer

WORKING WITH THE DATAREPORT DESIGNER

9

Visual Basic 6 is the first version that includes a report writer completely integrated in the IDE. Before using the DataReport designer, you must make it accessible from the IDE, which you do by issuing the Components command from the Project menu, switching to the Designer tab, and ticking the Data Report check box. Alternatively, you can create a new Data Project and let Visual Basic create an instance of the DataReport designer for you.

The DataReport designer works in bound mode only, in the sense that it's able to automatically retrieve the data to be sent to the printer or simply displayed in the preview window. It can export a report to a text file or an HTML file and also supports custom format layouts. The DataReport designer comes with a set of custom controls that you can drop on its surface in the same way as you do with forms and other designers. These controls include lines, shapes, images, and also function fields, which you can use to create summary fields in your reports. Another intriguing feature of this designer is its ability to print in asynchronous mode, which lets the user perform other tasks while the printing proceeds.

Information and Communication Technology DepartmentPalompon Institute of Technology

75

Working with the DataReport Designer

Page 2: LESSON 9 - Working with the DataReport Designer

WORKING WITH THE DATAREPORT DESIGNER

9DataReport Designer Toolbox Controls

These six controls aren't interchangeable with their counterparts you've always used for form design. Likewise, you can't use form design controls in DataReport Designer.

Control Type Description

RptTextBox Any data that will be supplied at runtime--through code or through a command--needs to be put in a RptTextBox. RptTextBox controls can be configured to look like plain text without any borders.

RptLine Use this control to draw lines on the report.

RptFunction This control performs functions on data groups in the report and can be used only in a group footer section of the report. It supplies functions such as row and value counting, sums, and so on.

RptLabel The RptLabel control is used to add static text to the report.

RptImage Use the RptImage control to add a picture to your report. This control, like the standard Image control, can hold bitmaps (BMP), icons, metafiles, or GIF or JPEG files.

RptShape You can use the RptShape control to add a variety of graphical shapes to your report, including rectangles, circles, and variations of them.

Special Characters Accepted in a RptLabel’s Property

Symbol Description

%d Current date (Short format)

%D Current date (Long format)

%t Current time (Short format)

%T Current time (Long format)

%p Current page number

%P Total number of pages

%i The title of the report

%% Percentage symbol

If, for instance, you wanted to include a page number, the Caption for the RptLabel control would be as follows:

Page %p of %P

VB will automatically substitute the page number and number of pages on each page of the report.

Setting Control Properties

Information and Communication Technology DepartmentPalompon Institute of Technology

76

Page 3: LESSON 9 - Working with the DataReport Designer

WORKING WITH THE DATAREPORT DESIGNER

9The controls you have dropped on the DataReport’s surface are similar to the standard controls you place on a form, but they belong to a different control library. In fact, you can’t drop a standard intrinsic control on a DataReport designer, nor can you place a control from a DataReport control library on a form or another designer. But you can move DataReport controls and align them as you would do with any regular control. You can’t use the commands in the standard Format menu, though, and you have to right-click on the control and use the commands in the pop-up menu.

DataReport controls react to the F4 key in the same way regular controls do, by displaying the Properties window. Because the RptLabel and RptTextBox controls are so similar to their standard counterparts, you should already be familiar with most of the properties you find in this window. For example, you can change the DataFormat properties of the txtOrderDate and txtShippedDate controls so that they display their values in long date format. Or you can change the txtOrderID control's BackStyle property to 1-rptBkOpaque and its BackColor property to gray (&HE0E0E0) so that order identifiers are highlighted in the report.

Printing the Report

The easiest way to print the report is to let the user start the operation interactively by clicking on the leftmost button in the DataReport preview window. Users can pick a printer from the list of installed ones and select a page range and the number of copies they want. They can even print to a file so that they can do the actual printing later. You can use several properties to modify the default appearance of the preview window:

‘Display the DataReport in a modal maximized window.DataReport1.WindowState = vbMaximizedDataReport1.Show vbModal

Information and Communication Technology DepartmentPalompon Institute of Technology

77