Sie sind auf Seite 1von 173

A New Tutorial: The Crystal Reports 9

Inside Crystal Reports 9: An Overview


Copyright 2004 by Karen Cristle

The newest release of Crystal Decisions Crystal Reports software builds upon an already
popular and powerful reporting tool. Theyve added some key new features that they
classify as power, productivity, flexibility, end user interactivity and general usability
enhancements. Crystal Reports has been one of my favorite reporting tools in the past
and it appears that the newest version of Crystal Reports will continue to be a great
reporting tool to use.
Here is a quick summary of the new features. The upcoming tutorial will explore many
of these areas in more depth.
Power
The report parts (charts, summary tables etc) can be integrated directly into portal or
wireless applications which eliminate the need to recreate reports for web or portal
environments. Also, Crystal now has extended SQL commands to provide the full SQL
support for databases. Crystal also has full support for Unicode strings which in this
global economy might be very important for large multi-national systems.

ww
Volume 10 No.1

January 2004

Productivity
Crystal Reports has many new features that increase productivity when creating and
working with reports. These include the Crystal Repository which stores objects such as
custom functions, SQL commands, text objects and bitmaps in a central library. This
library can be shared among reports and therefore can reduce ongoing management and
maintenance costs for your reports. Crystal Reports now has the ability to create your
own custom functions which can be written in Crystal or Microsoft VB syntax, and these
custom functions can be stored in the Crystal Repository. In addition, you can create
custom templates to ensure consistency in look and feel across multiple reports. To help
with creating your formulas and custom functions, Crystal Reports has enhanced the
Crystal Reports Formula Expert to include a Formula Workshop which is a centralized
tool featuring a codeless wizard, enhanced error checking and auto complete.

Flexibility
Crystal Reports now has a 100% Java SDK to enable developers to create and deliver
reports in a J2EE java environment. The Java report viewer can render reports to pure
HTML or WML. Crystal Reports can also take advantage of the Microsoft Visual Studio
.NET SDK. Crystal Reports also continues to support COM SDK development. These
options do give developers a range of choices. Crystal Reports can also be used with the
Crystal Reports Enterprise Report Application Server to add even more functionality and
independence. In fact, Crystal includes a Development and Test Licensed copy of the
Report Application Server along with Crystal Reports 9.

End User Interactivity


A new Interactive Zero-Client viewer has been introduced. This viewer provides much
improved end user interaction with reports. It includes smart search features, enhanced
exporting features such as being able to export search results to MS Word, MS Excel and
HTML. The HTML exports can be pasted into an email message and the recipients can
link back to the report and navigate to the data. Guided Navigation is a feature that
provides a more seamless path between report objects. Data contexts can be passed via

ww
Volume 10 No.1

January 2004

navigation links from one report object to another in the same report or in a different
report. Crystal Reports has also added support for Microsoft Smart Tags (Office XP).
This allows end users to insert report objects directly into Word or Excel documents (and
under some conditions into Outlook as well).

General Usability Enhancements


There are a number of general enhancements which include Side-by-Side installation
(installing Crystal 9 on the same machine as earlier versions), a re-architected database
query engine with support for Oracle, SQL-based DAO and support for multiple
databases in a single report, export improvements, cross-tab report improvements,
additional chart types, enhancements for working with formulas and a number of new or
improved wizards and explorers.
All in all it appears that Crystal Decisions has made some very key improvements to the
Crystal Reports software.

The Upcoming Tutorial


Over the next few months Ill be writing a tutorial which will explore many of these new
features as well as cover the basics of working with this powerful reporting software.
Well be exploring the following areas in working with Crystal Reports:
Working with List Reports
Grouping and Running Totals
Working with Formulas
Formatting and Enhancing Reports
Working with Cross-Tab Reports
Working with Sub-Reports
Working with Charts
Working with SQL
Exporting Data
Sharing Information
Until the start of our new tutorial
Karen Christle has educated many data base converts. Looks like another winning series!

ww
Volume 10 No.1

January 2004

Crystal Reports 9 A Tutorial

Part 1

Getting Started and Using The Report Wizard


Copyright 2004 by Karen Christle
After taking time to plan the report(s) you want to create using Crystal Reports its time
to start creating your report. Crystal can pull data from a number of different sources.
For this ongoing tutorial Im going to use a database that I created using MS Access. (if
you would like a copy of my database to use while you work through this tutorial, please
send me an email at karen.christle@cdilearn.com).
Todays lesson is going to focus on using the Report Wizard to create the database
connection and a simple grouped report. Future articles will delve into the many other
options that Crystal offers. You can create list reports, grouped reports, crosstab
(summary) reports, subreports and drill-down reports using Crystal. You can also do
mailing labels and OLAP (online analytical processing) reports.

When you start Crystal you will


normally be presented with the
Welcome screen, see left, which can
be turned off if you want.

ww
Volume 10 No.2

February 2004

Select the option to create a New Crystal Report Document Using the Report Wizard and
click on OK. You can also access the wizard by choosing File, New from the Crystal
menu.

Grouped and list reports fall under the Standard Category. Click OK to start the wizard.

ww
Volume 10 No.2

February 2004

Your next step is to tell Crystal where it is supposed to get the data for your report. In
order to see the tables in our MS Access database we need to Create A New Connection.
Click on the (+) beside the Create New Connection option so that we can establish the
connection we need.

ww
Volume 10 No.2

February 2004

You will see a list of all of the different types of data sources that Crystal can connect to
(and it is a large list). Select the (+) beside Access/Excel (DAO).

ww
Volume 10 No.2

February 2004

Click on the ellipsis button () beside the Database Name. Browse to find your database
and then click on OK. If your database requires you to logon, youll have to check the
Secure Logon option and provide the appropriate connection information. Once youve
selected your database, click on Next.

ww
Volume 10 No.2

February 2004

Your new connection will show up in the list. Expand it if necessary so that you can see
all of the various objects in your database. Then expand the Tables option so that you
can see all of the tables you can select from.

ww
Volume 10 No.2

February 2004

Were going to report on fields from the Registrations table. Click on Registrations and
then click on the (>) to add it into the Selected Tables area. Then click on Next.

ww
Volume 10 No.2

February 2004

Your next step is to select the fields that you want. Well choose RegistrationDate,
LastName, DistrictNumber and ClubName. Then click on Next.

ww
Volume 10 No.2

February 2004

If you want your report grouped you can select the column(s) that you want to group by
at this point. Well group by District Number. The default is ascending order. If you
want your report in descending order, change the option at the bottom right hand side.

ww
Volume 10 No.2

February 2004

Were not going to add any additional summary information for this report. So well just
click on Next.

ww
Volume 10 No.2

February 2004

Crystal also allows you to apply filters to restrict which rows you would like to see on the
report. We wont add any for this particular report so click on Next.

ww
Volume 10 No.2

February 2004

Your final step is to pick a template (look) that you like for your report. Once you have
found one that you like, click on Finish and put Crystal to work building your report for
you.

ww
Volume 10 No.2

February 2004

Your report will be displayed in Preview Mode for you. Because we created a group
report youll notice a list on the left hand side. This is a list of the different values from
your grouped field (in our case, District Number). You can click on any of these
numbers to see the details for that particular group. You can also page through the report
using the page forward/backward buttons at the upper right hand side of the report.
Click on the Design tab at the upper left hand side. This will show you the working
side of your report. If you want to modify columns (size, location etc) this is where you
need to be.

ww
Volume 10 No.2

February 2004

Theres a lot to the design mode in Crystal. We have the Standard and Formatting
toolbars at the top. Beneath the Formatting toolbar is the Insert Tools toolbar which
gives you access to several advanced options for your report. Beneath that is the Expert
Tools toolbar which gives to access to many of the experts in Crystal. The status bar
shows at the bottom and gives you information on the current state of the report or object
(if you have one selected).
You will also see your rulers, fields and field labels. In addition you can add guidelines
to help you align the object in your report.

ww
Volume 10 No.2

February 2004

Reports are divided into sections. These include the Report Header which displays once
at the beginning of the report. The Page Header contains information that you want
displayed at the top of each page in your report. The Details section is used to set up the
information you want printed for each record. The Report Footer prints once at the end
of your report. The Page Footer prints at the bottom of each page.
Because we created a Grouped Report we also see the Group Header and Group Footer
sections. These are generally used for column headings and summary totals respectively.
Click on the Save button to save your report and then close it.
Setting Default Report Options

Now that weve worked


through a connection and
a simple report, I want to
show you how you can set
some defaults for your
reports. These can be set
before you start creating a
report.
Choose File>
Options to see the dialog
box.

The Layout tab allows


you to set some defaults
for how you want the
Design View and Preview
to work.

ww
Volume 10 No.2

February 2004

The Database tab allows you to control how you want the objects from your database
displayed.

ww
Volume 10 No.2

February 2004

The Editors tab allows you to set default fonts, sizes, colors (if you dont apply a
template). The Reporting Tab allows you to set a default directory for your reports.

ww
Volume 10 No.2

February 2004

The Fields tab allows you to set defaults for formats for the different field types that
Crystal uses. Lets click on Date to change the default date format.

ww
Volume 10 No.2

February 2004

You can pick from one of the existing date formats, or click on Customize to make your
own. Choose a date format that you like and click on OK. Then click on the Number
button so we can see some of the options available for Number fields.

ww
Volume 10 No.2

February 2004

Here you can choose a number format and add a currency symbol if you like. Click on
the Customize button.

ww
Volume 10 No.2

February 2004

There is an option here on the left hand side (Allow Field Clipping). You may want to
uncheck this box. Crystal will truncate the display of fields if the data is too large for the
size of the field on the report. This can cause some confusion for someone reading the
report if they dont realize that the data has been clipped. If you uncheck this option,
you will see a series of #### signs if your field size is too small. Click on OK.

ww
Volume 10 No.2

February 2004

On the Fonts tab you can set default fonts for the different objects in your report. For
example, lets say we want group headings to appear larger than regular headings. Click
on the Group Name Fields button.

ww
Volume 10 No.2

February 2004

In the Font Dialog box you can make any adjustments that you would like.

ww
Volume 10 No.2

February 2004

The last tab controls Smart Tags (tips).


Spend some time looking at these different options and getting used to the Crystal
interface. Thats your homework for this month.
Anyone who has worked with Karen Christles tutorials know how good they are. This one is no
exception. Karen is a regular contributor to WindoWatch.

ww
Volume 10 No.2

February 2004

Crystal Reports 9

Tutorial Part II

The Report Wizard Creating Another Report


Copyright 2004 by Karen Christle
Last month we created a grouped report using the Report Wizard provided by Crystal
Reports. This month were going to create a slightly different grouped report. In this
case were going to get summarized information from two different tables.
Lets start the Wizard by selecting File > New and starting a Standard Report.

ww
Volume 10 No.3

March 2004

In the next step in the Wizard we are once again asked to identify our data source.
However, Crystal maintains a history of our data sources. If you expand the History
branch you should see the data source that we identified last month. Expand the tables
node and select the Registrations and RegisteredEvents tables for this report.

Click on Next well, heres a new screen for us. Because we are selecting data from
two different tables Crystal is going to ask us to explain how the tables are related to one
another. You will also notice that you have several options including asking Crystal to
automatically identify the most likely link by using field names or known keys for the

ww
Volume 10 No.3

March 2004

tables. You should also notice (if you are using the sample database) that Crystal is able
to find a match based on the field names.

So we can click on Next to continue with our report. The fields that we want are the
DistrictNumber, LastName, FirstName from the Registrations table and the AmtPaidUS
and AmtPaidCAD from the RegisteredEvents table. Our report is going to produce a
summary of who paid how much for their registrations.

ww
Volume 10 No.3

March 2004

After selecting your fields, click on Next. Were going to do two levels of grouping for
this report, first by District and then by LastName. Make sure you choose the
DistrictNumber as the top level group.

ww
Volume 10 No.3

March 2004

Click on Next. Because this is a grouped report and we have numeric fields in the report
Crystal is going to assume that we would like summary totals. Thats a nice feature
because most of the time this is quite correct we do want summary totals.

ww
Volume 10 No.3

March 2004

Go with the settings as they show and click on Next. I really liked this next screen.
There have been many times that Ive created a report where I only want the top few
rows returned. Here you have the option of indicating if there should be any grouping or
restrictions based on the summarized information. For example, getting just the top 5 or
bottom 5 rows! However, we want everything so were going to select the None radio
button.

ww
Volume 10 No.3

March 2004

Click on Next. The next step asks if we want to create a chart for the data for this
report its not required so well just continue on our merry way.

ww
Volume 10 No.3

March 2004

Click on Next. Were going to see some familiar steps from here on in. The next step in
the wizard asks if we want to filter out any records.

ww
Volume 10 No.3

March 2004

We dont want to filter anything, so just click on next. Our next step is to pick the
template we like. Find one that you like..

ww
Volume 10 No.3

March 2004

Click on Finish to generate the report which should look something like this:

ww
Volume 10 No.3

March 2004

Not too shabbyI see the Group information and one line for the registrant and the total
$ amounts. But, lets check another section just to be sure this is really what we want.
Click on the link for District 17on the left hand side.

ww
Volume 10 No.3

March 2004

Whoa.okay its really close but not exactly what I want. I want to see one line for
each name that is summarized not each individual RegisteredEvent line. The easiest
way to do this is to move the detail lines into the group header instant summary totals
when you do that..begin by clicking on the Design tab on the left hand side.

ww
Volume 10 No.3

March 2004

Okay we need to make some changes. First, because we could have two registrants
with the same last name and different first names we need to add the grouping that we
missed in the wizard. (okay, so I did that on purpose!) Click on the Insert Group button
(beside the ab button).

ww
Volume 10 No.3

March 2004

In this dialog box, select the Registrations.FirstName column and in ascending order.
Then click on okay.

ww
Volume 10 No.3

March 2004

Youll see the new group name a new group header and a new group footer. For now,
lets delete the Group # 3 Name field. Then were going to add some summary totals.
Click on the Summary button (look for the stylized E like autosum button in Excel)

ww
Volume 10 No.3

March 2004

We want a sum of the AmtPaidUS placed into the First Name group. Then create one for
the sum of the AmtPaidCAD field too. These summary totals will automatically be
placed into the footer area for Group 3.

ww
Volume 10 No.3

March 2004

Now lets move the LastName, FirstName fields into the summary band. (And take the
bold off of the totals). We also want to delete the detail AmtPaidUS and AmtPaidCAD
fields. (you will have to recreate the headings which can be done by copying other
headings and changing the text.

ww
Volume 10 No.3

March 2004

Finally collapse all of the bands that we are not using. Click and drag the top of the
dividing line below to the bottom of the dividing line above. (Look for a 2-way arrow).
At the end you should only have the Group Header #1 with the headings and the Group
Footer #3 with the totals.
Now click on Preview and lets take a look:

ww
Volume 10 No.3

March 2004

Much better! So, as you can see even if we didnt quite build things exactly right using
the wizard we did get a really good start that we could modify fairly easily to get just
what we were looking for!
Until next month.
Karen Christle has presented data base tutorials before. This, too, promises to be a winner. Stay tuned!

ww
Volume 10 No.3

March 2004

Crystal Reports 9 Tutorial

Part Three

The Report Wizard Creating Cross-Tab Reports and Mailing Labels


Copy right 2004 by Karen Christle
This month were going to work through two more reports using the Report Wizard,
cross-tab reports and mailing labels.
A cross-tab report is one that summarizes data by two or more items, for example,
summarizing total sales by sales person and product line. The summarized data appears
in a table or grid format. One of the items you are summarizing by will appear as the
column headings and the other will be displayed as the row headings.
I have found that cross-tab reports are one of the styles I use the most. On many
occasions management asks for summary data and a cross-tab is often the answer they
are looking for.

The first cross-tab report we are going


to create will give us a count of the
number of registrations we have by
district and by event. Start a new report
and select the cross-tab option from the
wizard.

In the next step of the wizard were


going to use our database connection
and select the Events, RegisteredEvents
and Registrations table.

ww
Volume 10 No.4

April 2004

The Events table has the event name column that we need, the Registrations table has the
district number and the RegisteredEvents table will be used as the source for counting the
number of registrati

ww
Volume 10 No.4

April 2004

This step shows us how Crystal has already joined all three tables together properly. The
links are based on field names or foreign keys that are defined in the database. Because
these links are correct we dont need to do anything here. Click on next.

ww
Volume 10 No.4

April 2004

This step in the wizard is where we identify the fields that we want to display as row and
column headings in our cross-tab and where we identify what field should appear as the
summarized data and what kind of formula or calculation we want performed.
Were going to use the DistrictNumber from the Registrations table as the columns
heading. Select it from the Available Fields box and click the right arrow beside the
columns box. Add the Description from the Events table as the row heading. Were
going to use the RegistrationNumber from the registrations table as our summary field.

ww
Volume 10 No.4

April 2004

However, what we want is a count of the number of registrations. In the formula drop
down box below the Summary Fields box select Count. Then click on Next.
The next two steps in the wizard ask about charts and filters we dont want either one
so just click on Next for both steps. The step that follows asks you to select a grid style.
Find one that you like and then click on Finish.

ww
Volume 10 No.4

April 2004

So heres our report as it stands. We can see part of the event names down the left hand
side, the district numbers across the top and a count of the number of registrations for
each event by district. Also, Crystal automatically produced a totals row for us so that we
can quickly see exactly how many registrations we had from each district and for each
event.
If you would like to widen the row headings so that you can see the whole event name,
click on the design tab so that we can modify the size of the field.

ww
Volume 10 No.4

April 2004

Widen the Row # 1 Name column to about 2.5 inches or so. Then click back on the
Preview tab to see how it looks.

ww
Volume 10 No.4

April 2004

And thats our first cross-tab report completed.


On to the second cross-tab report. This time I want a report that tells me what the total
Canadian $ and US $ that have been paid cross referenced by event and by club within
district. I want the events as the column headings and the district and club numbers
appearing as row headings. I want both US $ and CA $ in the grid. Start a new report,
using a cross-tab format and select the Events, Registrations and RegisteredEvents tables.

ww
Volume 10 No.4

April 2004

In the layout step place the Description from the Events table in the Columns box, the
DistrictNumber and ClubNumber from the Registrations table in the Rows box (make
sure you add the DistrictNumber first (to make sure the ClubNumber appears within the
DistrictNumber). Add the AmtPaidUS and AmtPaidCAD from the RegisteredEvents
table into the Summary Fields box and make sure they are both using the Sum function.
Go through the remaining steps of the wizard.

ww
Volume 10 No.4

April 2004

And heres our report. We can see the summary totals for each club, and notice that we
automatically have subtotals for each district (in the darker bands) and also an overall
summary is generated for us.
Lets take a look at creating Mailing Labels next. Start a new report and select Mailing
Labels from the starting dialog box.

ww
Volume 10 No.4

April 2004

All of the fields that we need are in the Registrations table so select that table from the
data source step of the wizard.

ww
Volume 10 No.4

April 2004

We want the FirstName, LastName, Address, City, ProvState, Country and


PostalZipCode fields in the next step of the wizard.

ww
Volume 10 No.4

April 2004

In the next step of the wizard you set up the labels themselves. If you are using Avery
brand labels (or if what you are using has an Avery brand equivalent) then this step is
really easy. From the Mailing Label Type drop down box simply select the Avery label
that you are using. Crystal Reports will automatically update all of the mailing label
settings for you.

ww
Volume 10 No.4

April 2004

If you are using some other brand you will have to set up the options. You may have to
set the label size, size of gaps between the labels and the margins. At the bottom right
you can see a summary that tells you how many labels will print across and down on the
page. This is a good way to confirm that the settings are correct.
You may also want to change the print direction I like to print labels across and then
down. That selection is made at the bottom left hand side.

ww
Volume 10 No.4

April 2004

Click on next for the filter step and then Finish to complete the wizard. Once you are
done you will see the labels in the format that Crystal Reports has used.

ww
Volume 10 No.4

April 2004

I wasnt really crazy about this format so Ive decided to make a couple of changes. I
want to rearrange the address so that the city & state/province are on the same line, the
country appears below that and the zip/postal code below the country. Also, I think the
names would look much nicer if they werent showing as two separated fields.
Lets click on the Design tab to make some changes. In order to reformat the address, I
need one more detail line (Details e). To add another detail section right click on

ww
Volume 10 No.4

April 2004

Details d and from the shortcut menu select Add Section Below. Crystal Reports will add
Details e to the report for you.

Now you can just click and drag to move the fields around. Put the PostalZipCode in
Details e. Put the Country in Details d. Move City to the left side of Details c and
ProvState to the right side of Details c. Click on Address and increase the size so that it
fits across the entire label.

ww
Volume 10 No.4

April 2004

Notice that you just change the first label (the one thats white). The other ones will
automatically adjust to match.
In order to print the name as a simple First Last format (ie. Karen Christle) we need to
create a formula field. The easiest way to do this is to start the Formula Workshop
wizard. This is accessed by clicking on the Formula Workshop button. It is located on
the lowest toolbar and has X+1 on it. You may want to maximize this window so that
you can more easily see all of the options.

We need to crate a SQL Expression Field. This is a field that is created by using columns
from the tables and manipulating them in some way. Click on SQL Expression Fields
and then click on the New button in the workshop toolbar. Name the new expression Full
Name.

ww
Volume 10 No.4

April 2004

In the right hand side we have three boxes. The first one shows us the existing columns
from our table. The second shows any built-in functions that we might want to use and
the third shows us the operators we can use to create our field.

Start by double clicking on the FirstName column. You will see that column added to the
work area. In the operators area expand the Strings option. String operators are those
that we can use for manipulating text data. Because I want to join the FirstName to the
LastName I need to use the Concatenate operator. Concatenating is joining two text
fields together.

Double click on the Concatenate operator and Crystal will insert the + for you. I want a
space between the names, so I manually typed in the quote-space-quote after the plus
sign. Its up to you to put in any kind of literal characters such as spaces, commas etc
that you want.

Double click on the Concatenate operator again and then double click on the LastName
column to add that one to the mix. Then make sure you click on the Save button.
Congratulatons! Youve just created a custom field!

ww
Volume 10 No.4

April 2004

Back in the Design window select View, Field Explorer from the menu. Then the list of
the fields that weve created will be displayed. In the Details a band delete the
FirstName and LastName fields.

ww
Volume 10 No.4

April 2004

Expand the SQL Expression Fields option in the Field Explorer. You can then click and
drag the Full Name field into the Details a band.

Now click on Preview and lets see how are labels look now..

ww
Volume 10 No.4

April 2004

And here we go labels looking much better than they did before.
So heres your homework create a new SQL Expression Field that concatenates the
City and the ProvState fields. Make sure you print a comma and space after the city. So
the label should look something like this:
Karen Christle
123 Main Street
Winnipeg, Manitoba
Canada
RX1 1X1
Until next month.

Karen Christle is a regular WindoWatch contributor, most recently providing us with articles in the data
base genre. This particular series bagan a few months back and can be picked up with the most recent
URL first on the list.

Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

ww
Volume 10 No.4

April 2004

Crystal Reports v. 9 Tutorial

Part 4

Working With Charts


Copyright 2004 by Karen Christle
This month were going to look at the charting component of Crystal Reports. On many
occasions I have found a chart more useful for conveying information than just numbers.
Were going to initially create our chart using the Report Wizard. Then well modify the
chart and look at the different options that are available to us. I want a report and chart
that simply shows the total $ by district. Lets start by creating a standard report.

ww
Volume 10 No.5

May 2004

From our database connection we need the Registrations and Registered Events tables.

Click on Next on the link page we can just use the defaults based on the field names.

ww
Volume 10 No.5

May 2004

For the fields we need the DistrictNumber from the Registrations table and the
AmtPaidUS and AmtPaidCAD from the RegisteredEvents table.

ww
Volume 10 No.5

May 2004

We want the report to be Group Sorted by District Number.

ww
Volume 10 No.5

May 2004

In the Chart page were going to select a Bar Chart. You can enter a title if you want.
For the On change of select District Number (this will eventually become the x-axis
values) and for the Show Summary well start with the AmtPaidUS. Once the report is
finished we can add the AmtPaidCAD. The Report Wizard assumes that you are working
with a single series.

ww
Volume 10 No.5

May 2004

In the last step of the wizard pick a template that you like. I went with Corporate Blue
for my choice. Then click on Finish and well take a look at our report.

ww
Volume 10 No.5

May 2004

Youll notice that our chart appears at the beginning of our report. We can change that
option (as well see later) if we want. I also noticed that the axis headings were printed
right overtop of the grid numbers.

ww
Volume 10 No.5

May 2004

You can simply click and drag the axis headings to move them further out. Adjust both
the y-axis (vertical) and x-axis (horizontal) headings to a location that doesnt cover the
grid values.

ww
Volume 10 No.5

May 2004

Crystal Reports lets you change many of the properties of the charts that you create.
Simply right click on the chart and you will see a number of selections in the shortcut
menu. The first one were going to explore is the Format Chart option.

There are three tabs available to us. On the Common Tab we have the following options.

ww
Volume 10 No.5

May 2004

Object Name
Use this field to define a name for the object you are formatting. This name is used when
dragging and dropping items to the repository (which we will be discussing in a later
lesson). A default name is created for each field in a report. If the default name suits you,
you can ignore this field.
CSS Class Name
Use this field to specify a class name for the report object you're formatting. The class
name can be used in your CSS (cascading style sheet) to indicate a unique style for the
selected report object.
Read-only
Use this option to make the selected report object read-only so it can't be formatted. This
means that someone who is viewing the report will not be able to change any of the
formatting of your chart. The formatting options that are usually available on the toolbars
or shortcut menus are suppressed (greyed out). This feature is for your convenience in
protecting report formatting; it is not intended to be used as report security.
Lock Position and Size
Use this option to lock the position of the selected report object so it can't be moved.
When you select this option, you cannot drag the object in the Report Designer and the
Size and Position command becomes inactive.
Suppress
Select this check box if you want to suppress the selected field. The field values won't
appear on the Preview tab, nor will they print.

ww
Volume 10 No.5

May 2004

Horizontal Alignment
This list contains the horizontal alignment types available for the field (for example, left,
center, and right).
Keep Object together
Select this check box if you want to keep all the objects from a given section together on
the same page. If there is enough room to keep them on the current page, the program
will print them on the current page. If there is not enough room, the program will print
them on the next page.
Close border on page break
If an object has a border and the object is split over two pages, you have two options: put
a border around each part of the split object, or display each part of the object with a
partial border. Select this check box to display a full border. Personally I prefer to see a
full border on each page. It always feels like something is missing otherwise.
Can Grow
This check box is useful for objects that contain variable length strings, such as memo
fields. It really doesnt apply to charts so you will notice that it is greyed out. Can grow
is useful for large text objects where you want the text to wrap and the object to simply
grow in height to accommodate more text.
Max number of lines
If you have selected the Can Grow check box, you can use this box to specify the
maximum number of lines by which the program can expand an object frame. Simply
enter the desired number of lines into this box or enter a 0 (zero) if you do not want to set
a limit.

ww
Volume 10 No.5

May 2004

Tool Tip Text


You can add Tool Tip text for the chart by clicking the Format Formula Workshop button
and entering text within quotation marks. Tool Tip text appears when you move your
mouse over the object.

ww
Volume 10 No.5

May 2004

The Border tab allows you to set the border size, style and color options.

The Hyperlink tab allows you to format the chart as a link to a website, email address or
file. If we were displaying the report in a format that was compatible for hyperlinking
we could let the user click on the chart to display the detailed report for example.

ww
Volume 10 No.5

May 2004

If you right click on the chart you can also invoke the Chart Expert. This expert allows
you to make changes to the chart itself (using a wizard-like dialog box). On the Type tab
you can change the type and subtype of the chart. As you can see, Crystal reports has a
large number of chart types that you can select from. (One of these days Ill figure out
how to read a Radar or Bubble chart!)

ww
Volume 10 No.5

May 2004

The Data tab is the tab we need to use to add the second series of values (the
AmtPaidCAD) to our chart. Start by clicking on the Advanced Button. From here you
can individually select the placement of the report (at the beginning Header or at the
end Footer). You can also make sure the On Change Of is set to DistrictNumber and
make sure both the AmtPaidUS and AmtPaidCAD are selected for the values.
The remaining tabs allow you set the options for the Axis (such as whether you want the
gridlines to display, what the range of values should be and how many divisions you want

ww
Volume 10 No.5

May 2004

for the axis). Seeing as the defaults are fine, which they usually are, we wont change
anything on this tab.
The options page allows us to change the overall chart options (such as if it should be in
color or black & white, whether data point values should be printed, background colors,
bar size and legend placement). On this tab, select bottom for the legend placement.
The Text tab allows you to customize the text for the titles as well as the font that is used.

ww
Volume 10 No.5

May 2004

After you click on okay you should see the legend at the bottom of the chart and the
second set of data in behind the original bars. Crystal tends to use colors that are similar
based on the template. Well change these colors later.

Other ways we can customize our chart include using the Chart Options from the shortcut
menu. If you right-click on the chart and select Chart Options and then select Template
youll see some additional choices that you can make for the chart type. In particular you
could change the layout to a clustered look instead of stacked (although I left mine as

ww
Volume 10 No.5

May 2004

stacked). You can also change the riser shape and if you want a 3-dimensional look
select the Use Depth option.

If you right-click on the chart and select Chart Options and then General you will see this
dialog box. On the General tab you can change the Gap Width along with another place
that you can change the riser shape & depth options. However, on this screen you can
control the direction and depth if you want 3-D effects.

ww
Volume 10 No.5

May 2004

The Layout tab gives you another place that you can change the bar style that you are
using for your chart.

ww
Volume 10 No.5

May 2004

On the Data Labels tab you can indicate if you want the values printing on the chart along
with the bars. I personally find that this is quite a cluttered look in a chart so I
generally do not use this option.

ww
Volume 10 No.5

May 2004

The Look tab allows you to change the color mode, legend display and some general
layout options for your chart.

ww
Volume 10 No.5

May 2004

The Display Status tab allows you to indicate which axis to display and whether or not
you want grid lines displaying (along with yet another chance to display the legend and
data labels).

ww
Volume 10 No.5

May 2004

If you right click on your chart and select Chart Options and then Titles you will see a
dialog box that allows you to set the various titles for your chart.

If you right click on the chart and select Chart Options and then Grid you will see a
dialog box that allows you to change the information for both the Data Axis and the
Group Axis (notice the tabs on the bottom left hand side of the dialog box).

The Data Axis (or Y-Axis) is your vertical axis. On the General tab you can indicate
where you want the axis to be displayed (left is the default) along with whether you want
to see the axis line or display in descending order.

ww
Volume 10 No.5

May 2004

The Labels tab indicates if the labels (values) for the axis should be displayed and
whether the highest and lowest labels should be printed.

ww
Volume 10 No.5

May 2004

The Numbers tab allows you to format the numbers. For example, you could set this to a
currency format if you want to.

ww
Volume 10 No.5

May 2004

The Grids tab allows you to control both the major and minor gridlines and how they are
displayed. You can also create all of your grids manually in this dialog box.
For the Group Axis (which is also the x-axis or horizontal axis) you can make the
following changes

For Grids do you want the gridlines to display (this would display vertical lines
between each bar) which looks more distracting than anything else. The General tab
gives you the choice of where to display the axis (bottom or top) and whether the axis
line should be displayed. The Labels tab lets you decide if the labels should be displayed
under each bar.
Before we go into the next set of options, you need to click on the bars that represent the
AmtPaidCAD (which are displayed in behind the US values). Then right click and select
Chart Options and Selected Item. This is going to allow us to change the color of the
bars.

ww
Volume 10 No.5

May 2004

In the Formatting dialog box we can select a color. However, I quite like the Gradient
look and feel. So lets click on the Gradient Button and see what our options are.

ww
Volume 10 No.5

May 2004

As you can see, we have lots of choices. Scroll through until you find a gradient color
blend that you like. Im partial to purples, so Ive selected a purple gradient color. Then
click on OK and OK again.

ww
Volume 10 No.5

May 2004

And there! We have our final chart.

ww
Volume 10 No.5

May 2004

As you can see the charting options in Crystal Reports are quite extensive, why not take
some time over the next month to play with some of the other styles of charts & the chart
options.
Until next month.

Karen Christle is a regular WindoWatch contributor, most recently providing us with articles in the data
base genre. This particular series bagan a few months back and can be picked up with the most recent
URL first on the list.

Crystal Reports: Getting Started and Using the Report Wizard: Part 3
Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

ww
Volume 10 No.5

May 2004

Crystal Reports 9.0 Tutorial Series

Part IV

Working With Other Data Sources


Copyright 2004 by Karen Christle

Over the past months I have received many emails about this tutorial series. One in
particular came from a fellow by the name of Amir. He was asking about how to connect
from Crystal Reports to data sources other than Access. In particular he wanted to know
about Oracle.

Well, seeing as Oracle is one of my favorite things in the IT world (Im an OCP-DBA,
OCP-Internet Application Developer and Oracle Certified Trainer) I decided that this
was a good time to tackle this very question.

Im going to show you just how easy Crystal makes it to connect to an Oracle database.
Then well take a look at using an Excel spreadsheet as a data source.

In the Report Wizard Data page you will see that there is an option for More Data
Sources. Oracle (and most other major databases fall under this category). After
selecting Oracle from the list, I was prompted to insert my Crystal Reports CD so that the
appropriate add-on could be installed. It took less than one minute to complete. (See the
image on the next page).

ww
Volume 10 No.6

June 2004

ww
Volume 10 No.6

June 2004

As soon as the install finished, I was presented with the dialog box that you see below.

ww
Volume 10 No.6

June 2004

I entered my connection information for my database. Even though the dialog box says
Oracle 8 Server in the title my database was an Oracle 9i database. Its installed on the
same machine as Crystal and the proper Oracle connection files (tnsnames.ora etc) are
already set up on my machine.

ww
Volume 10 No.6

June 2004

The Oracle Server connection was created for me. I had access to a number of schemas
in my database and could select the appropriate schema and tables from the dialog box in
a very similar manner as weve used in the past to get our data from Access.

ww
Volume 10 No.6

June 2004

After choosing the table I wanted, the remaining steps in the Wizard are no different than
Access.

ww
Volume 10 No.6

June 2004

I selected the columns that I was looking for.

ww
Volume 10 No.6

June 2004

I then chose the template I wanted (I didnt make any selections in the other steps in the
wizard). After clicking on Finish here was my report!

ww
Volume 10 No.6

June 2004

It was such a breeze to do this. This is one of the major strengths of Crystal Reports
theyve tried to make it really simple to get at your data!

Now, lets see what it takes to pull information from an Excel spreadsheet. To create my
source I simply exported the Registrations table from the Access database that I have
been using into an Excel file called Registrations.

ww
Volume 10 No.6

June 2004

After starting the Wizard, we have to make our choice for the data source.

(Notice how Oracle Server now shows up as one of the main connection types rather
than appearing under More Data Sources!).

ww
Volume 10 No.6

June 2004

The option we want to select for our Create New Connection is Access/Excel DAO.

ww
Volume 10 No.6

June 2004

Make sure the Database Type is Excel 8.0 and you can browse and find your spreadsheet
file by clicking on the browse button beside the Database Name.

ww
Volume 10 No.6

June 2004

Under the newly created connection you will see the table icon. It is generated from the
Excel table/list that was in the spreadsheet. You can use any Excel list (as long as it
conforms to the Excel rules for lists or databases). The table name is generated from the
file name.

ww
Volume 10 No.6

June 2004

The column names are generated from the column headings as they appear in your
spreadsheet.

ww
Volume 10 No.6

June 2004

The remaining steps in the report wizard are exactly the same as weve learned in the
past.
So, thats all there is to working with some of the other data sources that Crystal Reports
supports. Gotta love it when things can be this easy!!
Until next month..

Karen Christle is a regular WindoWatch contributor, most recently providing us with articles in the data
base genre. This particular series bagan a few months back and can be picked up with the most recent
URL first on the list.

Crystal Reports: Getting Started & Using the Report Wizard:Part 4:Working With Charts
Crystal Reports: Getting Started & Using the Report Wizard:Part 3
Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

ww
Volume 10 No.6

June 2004

Crystal Reports 9

Tutorial Series Part 6

Working with Running Totals


Copyright 2004 by Karen Christle
Running totals in reports can be useful and they are certainly a feature that my clients
have asked for in the past. With Crystal Reports it is quite simple to put together a report
that has running totals in it.
First, we must make sure we understand exactly what a Running Total is. Basically it is a
type of Summary total however we have more control over how the value is calculated
and when the value gets reset back to zero.
One important factor is the placement of a running total field in the report. It is very
important that it placed in the proper section (header of a group or detail for example).
As we go through a couple of examples of building a reports with running totals well
be able to see how the placement works. The following table summarizes the different
sections and explains how the running total will be calculated in each of them.
Section
Report
Header
Page
Header
Group
Header
Details
Group
Footer
Page
Footer
Report
Footer

How the running total will work:


Only the first record in the report will be included (this is generally not a good
place to put a running total)
All records up to and including the first record on the current page will be
included (again not always a good choice)
All records up to and including the first record in the current group will be
included (not a place I generally put running totals)
All records up to and including the current record will be included (I have put
running totals in this area many times)
All records up to and including the last record in the current group will be
included (this is also a common place for running totals)
All records up to and including the last record on the current page will be
included (I generally dont do totals at page levels I prefer group totals)
All records in the report will be included (like a regular summary field that
generates a grand total for the report I wouldnt use a running total here
just a simple summary is fine)

ww
Volume 10 No. 9

September 2004

Creating a Running Total for a Simple List Report


Lets create a simple list report and then add some running totals to it. First, start a new
report using just the RegisteredEvents table from our database:

The fields that we want are RegistrationNumber, AmtPaidUS and AmtPaidCAD. Were
going to create running totals for the two amount paid columns.

ww
Volume 10 No. 9

September 2004

We dont need any grouping or filters and you can select whichever template you like.
Once your report is selected, click on the Design tab so that we can add our Running
Total to the report. Click on the Field Explorer button in the standard toolbar at the top
of your screen. On the left hand side you will see the different kinds of fields that we can
add.

ww
Volume 10 No. 9

September 2004

Select Running Total Fields and then click on the New Button in the Field Explorer
Window.

ww
Volume 10 No. 9

September 2004

In the Create Running Total Field dialog box first give the field a name such as
RTotUS. Under the Available Tables and Fields select RegisteredEvents.AmtPaidUS,
then click on the arrow beside Field to Summarize. The Type of summary should be sum
(although you will notice that we have many different options available). Under the
Evaluate section were going to use For Each Record. This means that each individual
record will be added as it is displayed. Under Reset we want to choose Never. This
means that our total will accumulate right to the end of the report. If we were dealing
with a grouped report we could have it reset at the end of each group.

ww
Volume 10 No. 9

September 2004

Click on OK. Then create another Running total that does the same calculation for the
AmtPaidCAD.

Next we have to place the new summary fields into our report. It is imperative that these
go into the detail section so that we do get the running total accumulating for each record
in our report.

ww
Volume 10 No. 9

September 2004

To change the headings for your fields right click and select Edit Text. If you preview
the report you should now see our two running totals displayed.

ww
Volume 10 No. 9

September 2004

Creating Running Totals for a Grouped Report


Next, lets create a grouped report with running totals. Were going to set up two sets of
running totals. The first will do totals for the detail section; however we are going to
want the totals to be discreet for each district. The second set will create running totals at
the group level that shows the overall running total for all registrations..
To begin, select the Registrations and RegisteredEvents tables in a new report:

ww
Volume 10 No. 9

September 2004

Well need the DistrictNumber, RegistrationNumber, AmtPaidUS and AmtPaidCAD


fields from these tables:

ww
Volume 10 No. 9

September 2004

Make sure you group on the DistrictNumber field:

ww
Volume 10 No. 9

September 2004

And finally, remove any of the automatic summaries that are added by the wizard. Next
we are going to add four running total fields. We want two detail level running totals.
However, because I want the running total to start over again for each group we have to
make sure we change the reset at option.

ww
Volume 10 No. 9

September 2004

First, create a running total for the AmtPaidUS. In Reset, select the option On change of
Group and make sure it is selecting the District Number group. I used a name of RTotUS
so that I will be able to distinguish this later from the group level running totals I will
create.

ww
Volume 10 No. 9

September 2004

Do the same thing to create a detail level running total for the AmtPaidCAD.
Next well create the group level running totals.

ww
Volume 10 No. 9

September 2004

In this case well call them GTotUS. We want the total to include all records retrieved so
we want the For Each Record option and we dont want them reset. Youll notice that we
dont really specify that the total is going to be at a group level. This is controlled buy
the placement in the report. As soon as we place this total into the group footer section
well get the correct results. That is why placement is so important when dealing with
Running Totals.

ww
Volume 10 No. 9

September 2004

Create a corresponding total for the AmtPaidCAD field. Next we have to incorporate
these new summaries into the report.

ww
Volume 10 No. 9

September 2004

We need to place the two detail level totals into the detail band (section of the report).
Again, you can change the headings if you want. The group running totals must be
placed in the Group Footer band (section) as you can see in the graphic above.

ww
Volume 10 No. 9

September 2004

When you preview the report (and I moved down to group 19 so I could see the results
more clearly) you can see our different totals. In this case I can see that the detail level
running total for District 19 was $725 US. However the running total including all of the
records from the previous groups comes to $1,038. (However, its rather unusual to put
both of these totals into a single reportbut it does show how they work and how the
sections you use influence the calculations that are done.

ww
Volume 10 No. 9

September 2004

Now we have an idea of how to work with Running Totals a very useful technique for
reports.

Until next month


Karen Christle is a regular WindoWatch contributor, most recently providing us with articles in the data
base genre. This particular series bagan a few months back and can be picked up with the most recent
URL first on the list.

Crystal Reports: Working With Other Data Sources: Part 5


Crystal Reports: Getting Started & Using the Report Wizard:Part 4
Crystal Reports: Getting Started & Using the Report Wizard:Part 3
Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

ww
Volume 10 No. 9

September 2004

The Crystal Reports 9.0 Tutorial

Part Seven

Working with Parameters


Copyright 2004 by Karen Christle
Lets imagine a rather interesting scenario you create a report that lists all of your
customers who live in a particular city, for example Columbus, OH (which is where Im
moving in a few weeks). A few days later your users ask for an identical report for the
customers in Cleveland, then Dayton and the list goes on. Essentially you could end up
with a whole lot of identical reports to maintain.the only thing that changes is the city.
Another option (that will save you as a developer all sorts of headaches and grief) is to
simply build a report that asks the user to enter which city they are looking for..this is
what we call a parameter based report and thats what were going to do in this lesson.
When using parameters we must be aware of the different kinds of parameters that
Crystal supports and there are several.these are the data types that we can use:

Boolean a yes/no or true/false answer


Currency a dollar amount
Date a value in a proper date format
DateTime a value that includes both a date and time
Number a numeric value
String a character value
Time a value in a proper time format

The prompt (message that your users will see) for your parameter can be up to 4 lines and
254 characters long. Crystal Reports also allows you to create pick lists which gives the
users a list to select values from rather than having to type in a value. I am a big fan of
pick lists.
To use a parameter were going to create a simple grouped report the grouping will be
done on the district number. Then we will create the parameter that will allow the user to
select a district number to view when running the report.

ww
Volume 10 No.10

October 2004

To create the report we will use the Registrations table.

From the registrations table lets select the following fields..DistrictNumber,


LastName, FirstName, ClubNumber and ClubName.

ww
Volume 10 No.10

October 2004

In the step that asks about grouping were going to select the DistrictNumber. We
wont need any totals or filters and you can select the template that you like.

ww
Volume 10 No.10

October 2004

Make sure you are on the design tab and open the Field Explorer from the main menu
(its the button thats about 6 in from the right). In the Field Explorer select the
Parameter Fields option and then click on the New button.

ww
Volume 10 No.10

October 2004

Create a name for the parameter field and enter the value you want for the prompting text
(up to 254 characters). Then make sure you select the value type. In our case we want
string.
The options at the bottom left allow you to indicate if multiple values are allowed and
whether a user can enter a range or not. We want discreet values without a range and
well assume that the users wont need to enter multiple values.
We will set up a default value that way if a user is happy with the value they wont
have to enter anything just click on okay to run the report. Click on the Set Default
Values button.

ww
Volume 10 No.10

October 2004

The table that we want to apply this parameter value to is the Registrations table and the
column that we want to use is the District Number column. Im going to pick 64 as the
default valuethen click on okay.
Now that we have created the parameter, our next step is to tell the report to use the
parameter value when we run it. We do this by clicking on the Select Wizard. This
button is located on the lower toolbar and it shows a hand selecting a red circular disc
from a group of 3.

ww
Volume 10 No.10

October 2004

After you click on the wizard the following dialog box will be displayed and we use it
to indicate which report field the parameter will be used for. We need to select
DistrictNumber in this dialog box.

ww
Volume 10 No.10

October 2004

Click on OK and the following dialog box is displayed and this one allows us to associate
the parameter to the field.

The test we want should be is equal to and the value is the parameter (look for the
braces with the {?District Number}. This is the parameter field we created earlier.
Now, all we need to do is click on the Preview (or refresh button) to run our report.

ww
Volume 10 No.10

October 2004

You will see the Enter Parameter Values dialog box is automatically displayed and our
default value is shown. The user can overtype the value if they wish.
However, this does not give the user a drop down list (or pick list) of values to choose
from. Because that is such a handy way to set up parameters, lets go back and edit our
District Number Parameter so that it will display a list of values for the user.
Go back to the design view, right click on your parameter and choose Edit from the
shortcut menu. Click on the Set Default Values button again. This time were going to
add all of the available values from the left hand side. You can pick them one at a time if
you want to control the order in which the values will be displayed to the user.

ww
Volume 10 No.10

October 2004

You can also add a description to each value if you want. Click on OK and then OK
again.
Now, lets use the refresh button (looks like a lightning bolt) and rerun the report. This
time when you see the parameter form there should be a list of values the user can select
from.

ww
Volume 10 No.10

October 2004

This is a great way to setup a report it makes youre ongoing maintenance much easier
(mostly because you only have one report to look after) and it is really easy for the user to
select the specific information they want from the report.

Until next month


Crystal Reports: Working With Running Totals: Part 6
Crystal Reports: Working With Other Data Sources: Part 5
Crystal Reports: Getting Started & Using the Report Wizard:Part 4
Crystal Reports: Getting Started & Using the Report Wizard:Part 3

ww
Volume 10 No.10

October 2004

Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

At the annual OAEC summit in San Francisco, it was announced that Karen Christle was awarded the
Oracle Instructor of the Year! This is offered to only one instructor annually for recognition of outstanding classroom delivery, well beyond contributions to the Oracle community. She was awarded a
beautiful plaque honoring her excellent performance. Karen is a regular WindoWatch contributor.

ww
Volume 10 No.10

October 2004

Crystal Reports 9.0 Tutorial

Building Reports Manually


Copyright 2005 by Karen Christle
So far, I have always worked with the Wizard to create new reports. The wizard is an
excellent tool that does so much of the initial layout work that it is probably the best way
to start building reports. However, that doesnt mean its your only alternative. You are
able to build reports from scratch manually. In this tutorial were going to create a
simple listing report (with no groups) and a second report that groups the output and
produces a summary total as well.
List Report
In Crystal Reports, click on the New Report button and select the option to build a report
manually.

ww
Volume 11 No. 1

January 2005

You will be taken to the Database Expert to access the source database. Expand your
data base (my connection is stored under History) and for our first report we are going to
select the Events table.

Then click on OK.


Usually the field explorer is displayed on the left hand side automatically. If it isnt
being displayed you can click the Field Explorer button in the main toolbar of Crystal
Reports. In the Field Explorer area, expand the Database Fields option and if necessary
the Events table so that you can see all of the columns.

ww
Volume 11 No. 1

January 2005

For a listing report we are going to add the columns we want into the detail band of the
design page. Click and drag the EventCode, EventName, PriceUSD and PriceCAD
columns into the detail band leaving about 1/4 between them.
Notice that Crystal automatically creates headings in the Page Header area for you.

If you would like to add the current date and page numbers to your report you will find
these options under the Special Fields headings. Again, you can click and drag to add
them to your report. I have placed a date field at the top left of my report and a page
number field in the page footer band.

ww
Volume 11 No. 1

January 2005

You can use the text box tool ([ab]) in order to add heading text into the Report Header
band for your report. Format and resize the text box to suit your report.

ww
Volume 11 No. 1

January 2005

Once you are done, click on the Print Preview button to take a look at the report.

ww
Volume 11 No. 1

January 2005

The only thing I dont really like is the format of the date. If you click on the Design tab
in the work area you will be taken back to the design layout. From here, right click on
the data and select the format option.

ww
Volume 11 No. 1

January 2005

In the Format Editor select a date format that you like. Then you can preview your
report again.
As you can see, its not too bad to create a simple list report manually. It can be more
work to create grouped reports because not only do we have to add the fields etc, were

ww
Volume 11 No. 1

January 2005

also going to have to create the groups. Crystal Reports only creates the Report Header,
Report Footer, Page Header, Page Footer and detail bands when you create a report
manually,
Creating a Grouped Report Manually
Create a new manual report this time using the Registrations table as the source table.
Were going to create a report that lists the registrant names grouped by district and also
put in a summary field that shows how many registrations we have for each district.

ww
Volume 11 No. 1

January 2005

In the design window click on the Create Group button.and the following dialog
box will appear. Were going to
select the DistrictNumber as
our field and ensure that it is
being sorted in ascending
order.
The Options tab allows you to
change the name of the group
field, and indicate if the rows
for the group should be kept
together (this prevents a new
group starting near the bottom
of one page only showing
headings and all the rows on
the next page a small pet
peeve of mine). You can also
indicate if the Group Header
should be repeated on each
page of the report.

When the Design view is


displayed you will see that the
Group Header and Group Footer
are created for you. And the
group field is added to the Header
band (but no label or heading
information).

ww
Volume 11 No. 1

January 2005

I added a text box to add the District Number heading to the Group Header Band and also
added a text box to produce a Report Header.
You can add your fields to the detail band in the same manner as we did for the list
report. However, notice where the column headings display. They are placed into the
Page Header band. If you preview your report you will see that the headings really do
print above the group header text. Somewhat confusing isnt it.
My suggestion is that you click and drag the field headings into the Group Header band.
This is why we had the option earlier of repeating the Group Header band on each
page..much clearer reports.

ww
Volume 11 No. 1

January 2005

I would like to print a count of the number of registrations from each district in the Group
Footer. We can do this by adding a new running column and setting the options. Right
click on the Running Totals option in the Field Explorer and select new.

You will be prompted for a name for the field (I used TotReg). Because we are going to
use the count summary type we can select any field to summarize. If we were doing
sums or averages it would have to be a numeric field. Ive selected the LastName
column.

ww
Volume 11 No. 1

January 2005

I want each record counted individually and a discrete total for each group. So the
Evaluate should be For Each Record and the Reset should be On change of group (and
you must use the same field as you defined the group on).
Click on OK when you are done. You can then drag your new column into the Group
Footer band and add an appropriate label.

I also chose to add a date to the Report Footer and a page number to the Page Footer.

ww
Volume 11 No. 1

January 2005

And here we have our final product a grouped report that we built ourselves without
using the wizard.
As you can see, its not too bad building small reports from scratch manually but if this
was a report with lots of summaries and several layers of grouping I would much prefer
using the wizard.
Until next time!
Those of you coming in late will find URLs to her earlier articles in this series.
At the annual OAEC summit in San Francisco, it was announced that Karen Christle was awarded the
Oracle Instructor of the Year! This is offered to only one instructor annually for recognition of outstanding classroom delivery, well beyond contributions to the Oracle community. She was awarded a

ww
Volume 11 No. 1

January 2005

beautiful plaque honoring her excellent performance. Karen is a regular WindoWatch contributor.
Crystal Reports: Working With Parameters: Part 7
Crystal Reports: Working With Running Totals: Part 6
Crystal Reports: Working With Other Data Sources: Part 5
Crystal Reports: Getting Started & Using the Report Wizard:Part 4
Crystal Reports: Getting Started & Using the Report Wizard:Part 3
Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

Crystal Reports 9.0 Tutorial

Using the Crystal Repository


Copyright 2005 by Karen Christle
As you can tell to this point Crystal Reports is an awesome tool that offers us a great
many features to generate the information we require from our various databases. In this
last article in my tutorial series, I want to take some time to touch on a fabulous feature
that Crystal has within it.
This feature is called the Crystal Repository. It enables us to create our own custom
functions for calculated fields and store them in a library so that we can use them over
and over again for different reports.
For example, lets assume that we need to calculate sales tax on prices. Assuming we
have 20 reports that use this calculation, we have two alternatives to consider. First, we
could simply create a custom function in each and every report. That would essentially
mean that if the tax % ever changed we would have 20 reports to update. Not
necessarily the best use of our time wouldnt you agree? Alternately, we could create a
function and store it in the repository. Then we create a field in the report that references
the stored function instead. That way, we only have to change the function in the
repository once and all reports will pick up the changea much better idea.
First, lets create a simple report and review creating a custom calculation in the report.
Then well create a function, add it to the repository and change our report to use that
stored function instead.
To begin, create a new report using the wizard.

ww
Volume 11 No.3

March 2005

Use the RegisteredEvents table.

ww
Volume 11 No.3

March 2005

Choose the EventCode, AmtPaidUS and AmtPaidCAD columns.

ww
Volume 11 No.3

March 2005

Group by EventCode.

ww
Volume 11 No.3

March 2005

No ordering.

ww
Volume 11 No.3

March 2005

Go through the wizard (use defaults or no options) and select a template and finish off the
report.

ww
Volume 11 No.3

March 2005

We have decided that we need to add a column that converts the Canadian amount to US
(were going to use 1.25 as our conversion value). Click on Formula Fields in the Field
explorer and then click the New button.

ww
Volume 11 No.3

March 2005

Were going to create a new Formula named ConvCAD that takes the AmtPaidCAD
column from the Report Fields and multiplies it by 1.25. In the Formula Editor dialog
box build the formula by double clicking on the report field and add the * 1.25. Then
click on the Save button to create your new field.

ww
Volume 11 No.3

March 2005

Add your new formula to the report, and Preview the report to see the new calculated
column.

ww
Volume 11 No.3

March 2005

So, not too difficult and if you were only using this calculation in this report and not
using it in any other location then this is the approach I would use. However, if this is a
calculation you might want to use in additional reports the repository would be a better
solution. Lets initially start by creating a new Formula Field called ConvCADRep and
going into the Formula Editor.

ww
Volume 11 No.3

March 2005

Click on the Report Custom Functions option and click on New to create a new function.
Well call the function ConvCadRepFunc. This function is going to contain the code that
will do the calculation. The Formula field itself is going to be changed to call (or use)
this new function.

ww
Volume 11 No.3

March 2005

Enter the name of the function and then click on Use Editor.

ww
Volume 11 No.3

March 2005

The basic format for a function is Function (input parameter) and then the code to do our
calculation. Because functions are supposed to be generic youll notices that we do not
specify an actual field name here, just a parameter or variable name. You must specify
the data type and a name. CurrencyVar indicates that we will pass a currency value into
this parameter and valueToIncrease is the name of the parameter.
The calculation is to increase that parameter by multiplying it by 1.25 so that is the
calculation we have created. Dont forget the semi-colon its mandatory. After you

ww
Volume 11 No.3

March 2005

have created the function it will appear under the Report Custom Functions. You can
then right click on it and choose the option to add it to the Crystal Repository. Yes, it is
that simple!
After its been added to the repository, close the formula editor and lets edit the
ConvCadRep formula field we entered earlier. From the Formula Expert dialog box, you
can select our new function from the Repository Custom Functions, Crystal Repository.
Once you select the function, you will have to indicate which field from the report is
being passed into the function. Its here that we specify the AmtPaidCAD column in the
Value area of this dialog box.

Save these changes and add replace the ConvCad formula field that we used earlier
with this new field.

ww
Volume 11 No.3

March 2005

You will notice that we get the same results. And now we have the advantage of being
able to reuse this calculated value time and time again.
The Repository is definitely one of the key strengths of Crystal Reports. I highly
recommend its use for anything that is shared. However, for a calculated field that you
know you will only use once I would probably still consider storing it in the report.

ww
Volume 11 No.3

March 2005

Although, there is something to be said about keeping all of your calculated variables in
one place.
I have enjoyed writing this series and I hope Ive been able to successfully introduce you
to the key concepts and features of what I thinks is one of the best reporting software
tools available on the market today.
The earlier tutprial articles about Crystal Reports v. 9 can be located using the links
below:
Crystal Reports: Working With Parameters: Part 8
Crystal Reports: Working With Parameters: Part 7
Crystal Reports: Working With Running Totals: Part 6
Crystal Reports: Working With Other Data Sources: Part 5
Crystal Reports: Getting Started & Using the Report Wizard:Part 4
Crystal Reports: Getting Started & Using the Report Wizard:Part 3
Crystal Reports: Getting Started and Using the Report Wizard: Part 2
Crystal Reports: Getting Started and Using The Report Wizard: Part 1
Inside Crystal Reports 9: An Overview

Karen Christle is a regular contributor WindoWatch.

ww
Volume 11 No.3

March 2005

Das könnte Ihnen auch gefallen