Condividi tramite


Visual Basic Concepts

Writing Reports with the Microsoft Data Report Designer

The Microsoft Data Report designer is a versatile data report generator that features the ability to created banded hierarchical reports. Used in conjunction with a data source such as the Data Environment designer, you can create reports from several different relational tables. In addition to creating printable reports, you can also export the report to HTML or text files.

Possible Uses

  • Automatically create reports that are exported in HTML format for instant distribution on the Internet.

  • Create reports that show the sums of transactions occurring on a daily basis.

Data Report Designer Features

The Data Report designer has several features:

  1. Drag-and-Drop Functionality for Fields—Drag fields from the Microsoft Data Environment designer to the Data Report designer. When you do this, Visual Basic automatically creates a text box control on the data report and sets the DataMember and DataField properties of the dropped field. You can also drag a Command object 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 will be created on the data report; the DataMember and DataField property for each text box will be set to the appropriate values.

  2. 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 created on a new Toolbox tab named DataReport. 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, or Maximum. For more information about the Function control, see "Adding a Function Control to the Data Report."

  3. Print Preview—Preview the report by using the Show method. The data report is then generated and displayed in its own window.

    Note   A printer must be installed on the computer to show the report in print preview mode.

  4. Print Reports—Print a report programmatically by calling the PrintReport method. When the data report is in preview mode, users can also print by clicking the printer icon on the toolbar.

    Note   A printer must be installed on the computer to print a report.

  5. File Export—Export the data report information using the ExportReport method. Formats for export include HTML and text.

  6. Export Templates—You can create a collection of file templates to be used with the ExportReport method. This is useful for exporting reports in a variety of formats, each tailored to the report type.

  7. Asynchonous Operation—The DataReport object's PrintReport and ExportReport methods are asynchronous operations. Using the ProcessingTimeout event, you can monitor the state of these operations and cancel any that are taking too long.

Topics

Sample Application

The sample application named prjNwind corresponds to the project built in the series of topics that begin with "Creating a Simple Data Report." If you have installed the Visual Basic sample applications, the file can be found in the . If you have not installed the sample applications, the file can be found on the MSDN™ CD that accompanies Visual Basic.