Creating a Report with Crystal Reports 10 - dummies

Creating a Report with Crystal Reports 10

By Allen G. Taylor

When you start Crystal Reports 10, generally you want to do one of three things: create a report, modify a report, or run a report against the data in your database. Reports take data from a database, process it, format it, and then output it to a printer, computer screen, or Web site.

Crystal Reports comes with a sample database you can use for practice. It’s a Microsoft Access database for a fictitious company named Xtreme Mountain Bikes Inc.

The xtreme.mdb database contains a number of database tables that are representative of the tables a real bike manufacturer might maintain. The tables are filled with sample data that you can manipulate and display with Crystal Reports. You can use this sample data as the basis for your first report.

To create a report, you need to know a few things:

  • Which tables in the database contain the data you want
  • Which data items you want in those tables
  • What manipulations of the data must be performed to give you the information you want
  • How you want your report to be formatted
  • Whether the users of your report retrieve it from a black-and-white printer, a color printer, a local computer screen, or a Web site

For the purposes of this introduction (and for now), imagine you already know all those things.

Starting Crystal Reports 10

You’ve probably chosen Crystal Reports because you have a database that contains information that’s important to you. In all likelihood, the data in that database changes with time, and you want to be able to keep up with its current status. You could retrieve the information you want by making SQL queries, but that would be too much like work. It’s far better to create a report with Crystal Reports, and then run the report whenever you want the latest status of the information of interest. You have to create the report only once, but you can run it many times, getting the latest results with each successive run. You don’t have to learn SQL or any other method of pulling data out of databases. Reports created with Crystal Reports are easy to build, easy to read, and easy to understand. What could be better?

The first step to creating a report is to launch Crystal Reports from the Windows Start menu. When you do, the Crystal Reports main window appears, displaying the dialog box that welcomes you to Crystal Reports.

You are invited to choose from three options. You can create a Crystal Reports document using Report Wizard or by starting with a blank report. Alternatively, you can open a report that already exists, either to change it or to run it.

Although Report Wizard can be a time- and labor-saver, it does constrain the form of the report. So this chapter takes you right to the point and shows you how to create a report your way, starting from a blank report instead of using Report Wizard.

Using the Blank Report Option

To create a report from scratch, starting with the blank report option, follow these steps:

1. Start Crystal Reports.

The Welcome to Crystal Reports dialog box appears.

2. Select the As a Blank Report option, and then click the OK button.

The Database Expert dialog box appears, which shows possible places to find the source of your data.

3. In the Available Data Sources pane, click the plus sign to the left of the Create New Connection folder to expand it.

This is the folder you choose whenever you’re creating a report from scratch. When you have connected to a database, Crystal Reports remembers where it is.

4. Double-click the database type that matches your data source.

Crystal Reports recognizes a variety of different database types. You must select the right one. If you don’t know which type is correct, ask someone familiar with the data source. To follow along with the example, double-click Access/Excel (DAO). The Access/Excel (DAO) dialog box appears, which asks how to connect to your data source.

5. Click the ellipsis (…) button to the right of the Database Name box.

The Access and Excel files on your system appear. This example uses an Access database file named xtreme. This may not be as easy as it sounds — the file was located at D:Program FilesCrystal DecisionsCrystal Reports 10SamplesEnDatabasesxtreme.mdb.

You may have to browse to find this file on your system.

6. Click the Finish button.

Database Expert reappears, with the xtreme database connected.

7. Expand the Tables node, and then double-click the table on which you want to base your report.

The tree in the Available Data Sources pane consists of a number of nodes, some of which branch off from others. Every data source has four of these nodes branching off from it: Add Command, Tables, Views, and Stored Procedures.

8. To follow along with the example, expand the Tables node and then double-click Product.

Doing so copies the Product table from the Available Data Sources pane to the Selected Tables pane.

9. Click the OK button to close Database Expert.

A blank report fills the window.

The Design tab (on the left edge) shows five sections of the report:

  • Report Header: Appears only at the top of the report and is the first thing that a viewer sees.
  • Page Header: Appears below the report header and at the top of all the other pages in the report.
  • Details: The actual content of the report.
  • Report Footer section: Appears after the last detailed information in the report.
  • Page Footer: Appears at the bottom of every page of the report.