Introduction to data report
Helps you design a report that displays fields and records from the underlying table or query.
A report is an effective way to present data in a printed format. You can display the information the way you want to see it
You create the report using graphical object called Data report designer controls. Data report designer controls. Include: a data-bound Textbox control, a function control which displays calculated figures, and Image control for inserting graphics, labels that display captions, and a line and a shape control that graphically organizes the data.
Note: Although the data report designer controls are similar to Visual Basic intrinsic controls, data repot designer controls have a limited subset of features. When the Data report designer is added to a project, the designer’s controls are placed in the Visual Basic toolbox on a new tab named data report and can be used only in the Microsoft data report.
Creating repots is a main function of any good business application. A system might have useful, data, but without a coherent way to present it, the numbers are meaningless. So, Microsoft provides a Data Report designer. Which is used to generate eye catching reports. It is used in conjunction with a data source such as the data environment designer.
The Data Report generates reports using records from database. To use it.
- Configure a data source, such as the Microsoft data environment, to access a database.
- set the Data member property of the data report object to a data member.
- set the data member property of the Data Report.
- Right click the designer and click retrieve structure,
- Add appropriate controls to the appropriate sections.
- Set the data member and Data field properties for each control.
- At run time, use the show method to display the data report.
Use the data report object to programmatically change the appearance and behavior of the data report by changing the layout of each section object.
The data report designer also features the ability to export reports using the export report method. This method allows you specify an export format object, from the export formats collection, to use as a template \for the report.
Part of the Data Report
The Data Reporter designer consists of the following objects:
Data Report Object – Similar to a Visual Basic form, the Data Report object has a visual designer. It is used to create the layout of a report.
Section object – The Data report designer contains sections which helps to configure the report more elegantly. The sections of the Data report designer is explained in the next section.
Data report controls – special controls that only work on the data report designer are included with it. These controls are found in the Visual Basic toolbox, but they are placed on a separate tab named “Data Report’
Report Designer – User the report Designer to create and modify reports. When the report designer window is active, Visual Basic display report controls toolbar.
Data report designer features – the data report designer has several features:
Drag and drop functionality for fields – When fields are dragged from the Microsoft data environment designer to the data report designer, Visual Basic automatically create a text box control on the data report and sets the Data member and Data Field Properties of the dropped field. A command object can also be dragged from the Data environment designer to the data report designer. In that case, for each of the fields contained by the command object, a text box control with be created on the date report; the Data member and Data field property for each text box will be set to the appropriate values
Toolbox controls – The data report designer features its own set of controls. When a Data report designer is added to a project, the controls are automatically crated on a new toolbox tab named Data report. Most of the controls are functionally identical to Visual Basic intrinsic controls, and include a label, shape, image, textbox, and line control. The sixth control, the function control, automatically generates one of four kinds of information: sum, average, minimum, of maximum.
Print Report – When a report is generated, it can be printed by clicking the printer icon on the toolbar.
Note: A printer must be installed on the computer to print a report |
File export – in addition to creating printable reports, it can be exported to text files, by clicking the export icon and specifying text file name.
Section of the Data Report Designer
The Data report designer contains the following sections:
Report Header – Contains the text that appears at the very beginning of a report, such as the report title, author, or database name.
Page Header – Contains information that goes at the top of every page, such as the report’s title.
Group Header/Footer – contains a “repeating” section of the data report. Each group header is matched with group footer. The header and footer pair are associated with a single command object in the data environment designer.
Details- Contains the innermost “repeating” part (the records) of the report. The details section is associate with the lowest level command object in a data environment hierarchy.
Page Footer – Contains the information that goes at the bottom of every page, such as the page number.
Report Footer – Contains the text that appears at the very end of the report, such as summary information, or an address of contact name.
Data report controls – When a new data report designer is added to a project, the following controls are automatically placed in the toolbox tab named data report.
- Text Box control (Rpt text Box) – Holds the data that is supplied at runtime.
- Label control (RptLabel) – used to identify fields or sections.
Figure: Data controls for Data report on the Toolbox.
- Image control (RptImage) – enables to place graphics on a report.
Note: This control cannot be bund to a data field. |
- Line Control (Rpt Line)- lets to draw rules on the report to further distinguish
- Shape Control (Rpt Shape) – Enables to place rectangles, triangles, or circles 9and ovals) on a report.
- Function control (Rpt Function) – A special text box that calculates values as the report is generated.
Printing a Data Report
Printing a data report can be accomplished in one of two ways. The user can click the print button that appears on the data report in print preview mode (using the show method), or you can programmatically enable printing using the print report method. If an error occurs during printing, trap it in the error event.
Choosing to display a print dialog box
When printing a report programmatically, you have two choices: to print by displaying the print dialog box or by printing without displaying the dialog box.
To display the print dialog box.
- Add a command button to a form.
- In the button’s click event, place the following code: data report1. print report true.
The print dialog box allows the user to select a printer, print to file, select a range of pages to print, and specify the number of copies to print.
Note: Printers must be installed on the computer in order to present a choice of printers |
Printing without a Dialog Box
In some cased, you may wish to print the report without user intervention. The print report method also gives you the option of selecting a range of pages to print, either all, or a specified range.
To print without displaying the dialog box
- Add a command button to a from
- In the button’s click event, place the following code:
Data report1. Print report false
Or, to specify a range of pages to print, use the code below:
0 Data report1 print report false, rpt created with the data report designer.
Print Report Method
At run time, prints the data report created with the data report designer.
Syntax
Object. Print report (Show Dialog, Range, and Page From, Page To)
The print report method syntax has these parts:
Past description object required. And object expression that evaluates to an object in the applies to list. Show dialog Optional. A Boolean expression that determines if the print dialog box is shown. Range optional. Sets an integer that determines if all the pages in the report will be executed or a range of page, as shown in setting. Page from optional. An integer that sets the page from which to start printing. Page to optional. An integer that sets the page at which to stop printing.