|
To access the contents, click the chapter and section titles.
Peter Norton's Guide to Visual Basic 6
(Publisher: Macmillan Computer Publishing)
Author(s): Peter Norton
ISBN: 0672310546
Publication Date: 09/09/98
Chapter 14 Using Crystal Reports
In Chapter 13, Using the Printer Object, you saw how to send information to a printer from within a Visual Basic program. However, creating great-looking reports requires a unique program designed specifically for that purpose. Crystal Reports is a complete reporting tool included on the Visual Basic product CD-ROM. By using this reporting tool, you can create professional-looking reports to display onscreen with your application or send to a printer.
Now that you know how to use the Printer object, you will learn how to use the Crystal Reports product to design and create professional-looking reports to add to your Visual Basic program. In addition, you are going to learn how to run the reports from within the Visual Basic program using the Crystal Reports Custom control.
Explaining Crystal Reports
Before learning how to create a report, you must know what Crystal Reports is and what features and tools are available to you when using it. By knowing and understanding the tools, features, and options available to you in Crystal Reports, you can design the reports you need for your application. Crystal Reports is a powerful program for creating custom reports, lists, and labels from the data in your application database. When Crystal Reports connects to the database, it reads the values from the fields you selected and places them into a report, either as-is or as part of a formula that generates more complex values. Crystal Reports is designed to work with the different types of data that can be found in a database, such as the following:
- Numbers
- Currency
- Text
- Dates
- Boolean
A wide range of built-in tools can be used to manipulate data to fit the requirements of the report. These tools enable you to
- Create calculations
- Calculate subtotals and grand totals
- Convert data from one type to another
- Calculate averages
- Count the total number of records in a query
- Test for the presence of specific values
- Filter database records
- Perform date calculations
The data from your database can be placed wherever you need it on the report and can be highlighted by changing the fonts or font sizes. Using Crystal Reports, your reports can be as simple or as complex as your needs require. After you have designed a report for your application, you can use it within the application or as a template to create other similar reports. Crystal Reports was created to enable both technical and nontechnical users to create customized reports quickly and easily from a variety of databases. Although most database systems include their own report generators, they are usually too difficult for nontechnical people to use, and they generally require a good understanding of how that database works.
Note: No matter how much you change the data in a report, it will not be changed in the database.
Crystal Reports connects to almost any database system available today. Actually, there are two unique methods used to connect to a database: Data File and SQL/ODBC. The Data File method is designed for the smaller, PC-based databases, such as dBase and Microsoft Access. The SQL/ODBC method uses an ODBC (Open Database Connectivity) connection, which connects to any database that supports it. Some databases in this group are Microsoft Access, Oracle, Sybase, and Microsoft SQL Server.
Note: Although ODBC and the newer OLE/DB connections are generally used for complex server databases, they can also be used to access Paradox and, if needed, Microsoft Access.
Taking a Quick Tour
When you start Crystal Reports, you see the main application window (see Figure 14.1). After you begin working with a report, the main window contains two separate tabbed windows that you use to design and preview the report you are working on. Both the Design and Preview windows are actually included in a child window within the Crystal Reports application. These windows have their own unique features and functions that enable you to work with your report design in slightly different ways.
Figure 14.1. The Crystal Reports main window is used to design and modify a report.
In the next several pages, you will see the different work areas of Crystal Reports and the tools that are available to you. After you have a working knowledge of these features, you will create a simple report and then run it from a Visual Basic program.
|