200 likes | 217 Views
This tutorial discusses the importance of reports in enterprise applications and provides a step-by-step guide on how to build and use reports using Visual Basic 6.0.
E N D
Enterprise Development Using Visual Basic 6.0 Autumn 2002Tirgul #13 ‘Tirgul’ # 13
Objectives • Building and using reports ‘Tirgul’ #13
Why reports • Essential in many applications • Customer care: • Telephone bills • Credit card expenses • System admin. • Last used web site • Data base scheme ‘Tirgul’ #13
Name Age Grade Jason 25 89 … … … Type of reports • Graphical: • Graph • Cake • Textual • Table of data ‘Tirgul’ #13
VB Reports • Based on Database data • To be accurate – Using a Recordset Database Sample report RS ‘Tirgul’ #13
Adding reports (1) • Open Project components ‘Tirgul’ #13
Adding reports (2) • In the Designers tab, Add “Data Report” ‘Tirgul’ #13
Adding reports (3) • Add a data report to the project ‘Tirgul’ #13
Project tree ‘Tirgul’ #13
The data report object Header area 1st report page Page header Each report page Detail Main data area Page footer Each report page Header area last report page (Total…) ‘Tirgul’ #13
Sections of the Data Report Designer • Report Header - Text that appears at the very beginning of a report, such as the report title, author, or database name. • Page Header - 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 a group footer. • Details - contains the innermost "repeating" part (the records) of the report. ‘Tirgul’ #13
Sections of the Data Report Designer 2 • 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 or contact name. ‘Tirgul’ #13
Data Report Controls 2 Report Label Report Text box Report Image Report Shape Report Line Report Function ‘Tirgul’ #13
Data Report Controls 2 • TextBox Control (RptTextBox) - allows you to format text, or assign a DataFormat. • Label Control (RptLabel) - allows you to place labels on the report to identify fields or sections. • Image Control (RptImage) - enables you to place graphics on your report. Note that this control cannot be bound to a data field. ‘Tirgul’ #13
Data Report Controls 3 • Line Control (RptLine) - lets you draw rules on the report to further distinguish sections. • Shape Control (RptShape) - enables you to place rectangles, triangles, or circles (and ovals) on a report. • Function Control (RptFunction) - a special text box that calculates values as the report is generated. ‘Tirgul’ #13
Setting data • Its all about data source: • While • RS is a Recordset containing data Set DataReport.DataSource = RS ‘Tirgul’ #13
Setting Recordset fields • Done In design time. • In the Details section, create a TextBox and set its DataField property to the corresponding field in the table • Repeat for each field you want to show ‘Tirgul’ #13
Setting report functions • Same as setting data • Common: • Sum/Min/Max… ‘Tirgul’ #13
Setting other data • Other usefull data: • Current page • Total number of pages • Date/Time ‘Tirgul’ #13
Summary before examples • Make sure you have an existing RecordSet. • Design the report properly (add logo/shapes) • Put ONLY Database fields in the detail section • Lets see… ‘Tirgul’ #13