You are on page 1of 14

Crystal Reports 9 usage

To use Crystal Reports 9 (known as CR for rest of document) first start the
program.

Above is a screenshot of the crystal reports opening dialogue. This is pretty self-
explanatory. If you want to start a new report you should choose the Report Wizard
option, if you want to work on an existing report then open it with the open dialogue
halfway down the dialogue.

Next are the steps in creating a new report, using the report wizard.
All reports can be created from the standard template. I.e. you can still make a cross-tab
report or a drill down report or drill-down report from a standard report. Go ahead and
click ok to move to the next screen.
This is the connection dialogue. To work off of the JDS sql database, use a dsn to connect
to it, this is the easiest way of connecting right now, as it will allow the easiest way of
transferring the connection to the Tippecanoe sql connection when the time comes. Both
the jds and Tippecanoe fields in the database for jds.2go are set up the exact same way,
so if you point the report you are working on to a dsn that points to the jds database, you
can just change what is in the dsn to point to the Tippecanoe server when the time comes
to deploy the reports. Currently there is a dsn that points to the jds database located in
/dev/reports/jdssql.dsn on the T drive.
when you click on “ Create New Connection -> ODBC (RDO) “ this screen will show.
This is where you will point the report at the dsn. Click on the radio button by Find File
DSN and then navigate to the dsn that you want to use. Click next when you have
selected the correct dsn.
Next you will have to put in the username and password to connect to the database. I am
not putting the current information for this in this document since it will be posted to the
web, but if you don’t know these items then ask someone else on the team. NOTE: from
here on out I will be using a connection to a local mdb to demonstrate things because I
am not able to connect to the jds sql server from where I am. So the screenshots may look
slightly different from what you are looking at while working on a report, but the ideas
are the same.
After you have made a connection, it will show in the list on the left. It will show you the
tables in the database and also the stored procedures. Queries that are storied in the
database will show up as tables. Here is where you need to know the data. What you need
to do is to select the tables that you need. With CR you need to be able to link all of the
tables to a single table because CR does not support multiple starting locations. So if you
need to use multiple tables then always start by adding the main table that everything else
links from.
go ahead and select the tables you want and they will be moved to the right side. Then
click the next button
Now you need to link the tables. CR might try and auto link the tables, if this happens
then be sure you check the links to make sure that they are correct. What I like to do is to
erase all of the links and start over but putting in the correct links. To create a link click
and drag a field from one of the tables to the corresponding field in another table.
This shows what a link looks like (NOTE remember that I am demonstrating from a
sample database so that is why the fields do not match up. Just remember that most of the
links will probably be mainID to mainID)
After creating the links you will go to this screen. This is where you can select fields
from the tables that will be used in the report. Do not worry if you miss a field, as you
can add them in later, as well as other tables if need be. After selecting the fields I will
click on the finish button so that I can start working on the report. You could go ahead
and do grouping, record selection, or choose a template, but I find it is easier to do these
things from the report editor instead. I will explain these later.
After clicking finish, the report editor will show. The default view is the preview window
for the report. CR simply takes all of the fields and lists them across the top of the report
after you create a new report, so if you are using a lot of fields then everything will show
up very crowded together and the field sizes might be very small. Don’t worry about this
as you now get to start building the report. One thing that is not shown on the default
view is the Field Explorer which I opened before taking the screenshot. To show the
Field Explorer go to View->Field Explorer. From here you can do a lot of things,
including add new fields to the report from the database and add Special Fields (things
like print date for the report, page number and things like that)

From here on out I suggest you go look at the sample report found at
/dev/report/sample1.rpt. It is a good example to look at. I will explain functions and
features that can be used when creating a report.
Lets start here by explaining the parts of the report. This is the design window, to switch
between design and preview windows use the tabs near the top left of the page. First off,
lets look at the left side of the design window. You can see the Report Header, Page
Header, Details, Report Footer and Page Footer. The details section is probably the main
section to worry about. This section will repeat for every record in the field list. If you
look at the sample report you can see how the details section is repeated over and over for
each record. You can even see the details section on the left side of the preview page (it
has a P by the details sections) The page header section will be shown on every page, as
will the page footer section. The page footer section is usually used to show things like
page number.

Now I will explain field types. There are 4 main field types. The first type are special
fields. These fields can be inserted from the field explorer. These fields include page
numbers, print date and print time and they act like database fields in that they can be
manipulated the same way. The second type are database fields. These are the fields that
when put in the details section will show the individual field values when previewed. The
third types are formula fields. Formula fields are very versatile, to create a formula field
use the field explorer and either right click on ‘Formula Fields’ and go to new or left
click on ‘Formula Fields’ and click on the new button at the top of the Field Explorer.
When you create a new formula you need to input a name then choose the Editor. Here
you can do a lot of things. In the Functions window you can use all sorts of different
functions to work with any formula that you are working on. Formulas are good for
working with dates, any numerical formulas and they can be used with any of the
database field.

(you can do grouping on dates easier with the built in group function, but for this
example we will use a formula to show how formulas work)
For example, lets say we want to display all of the new clients in the past year and group
them by month so that we can create a bar graph that shows the clients by month. I will
get into graphing, grouping and drilling down from a chart in a little bit. But to start this
sample report lets say we have a table with the clients entry date, main id, name and age
and we put all of these fields into the report. Lets start by creating a new formula field
that will output a 1, 2, 3…. 12 based on the month of the clients entry date. So we create
a new formula called month. This is a simple formula which is basically
‘month({table.field})’ (without the ‘ ). Formulas can be created with if-then-else
statements, they can output numbers, strings or Boolean values. Practice makes perfect
with these as you can do all kinds of things with formulas. Now that we have a field that
has a number we can create a group based on this formula field. But first we have to add
the formula field to the report, so you can just drag the formula field from the field
explorer list to the details section. This will result in the formula being calculated for each
record in the list. Now you can go to Insert-> group and create a grouping from this
formula field. Search for the formula field name and click ok. You will notice that a
Group Header and Footer are added to the report. You do not have to use these, but they
are nice if you want to show the group name or other information about the group.

Text fields are basically fields that you can put text into. You can also insert database
fields or formula fields in text fields so that the database fields appear in line with the text

For example lets say you want to put this at the bottom of every page: Page 1 of 10.
There are built in page and total page number special fields. We will show these as [Page
Number] and [Total Pages] Now we could create two text fields and line them all up like
this: [Page: ][Page Number][ of ][Total Pages]. Well if we have 100000 pages, page 1
will show: ‘Page: 1 of 100000’. If we put all of this inline by dragging the special
fields into one big text field it will show up as ‘Page: 1 of 100000’ and will dynamically
size as the pagenumber grows to include more space.

Record Selection:
You will not need to worry about record selection. JDS.2GO generates a selection
formula that is passed into CR which limits the records to only the ones needed/selected
by the user. If you need to do manual selection of records you can go to Report->Select
Expert and basically build a formula to limit the records that you use in the report.

A few other odds and ends:

The rulers will often show little arrows which basically point to the start of fields. I
cannot stand these arrows so I usually get rid of them by dragging them off the rulers and
they disappear. By default the fields will snap to the grid, but little arrows will overrule
the snap to grid. So I usually get rid of the arrows and just use the grid, but do whatever
you find easiest.

One thing you should never do is to save data with the report. There is an option in the
File menu called ‘Save Data With Report’ which will save a current snapshot of the data
with the report. This is bad! We want reports to contain up to date data, so if this option is
not used the report will go pull data every time the report is generated. So please do not
use this option!

Please fill out information about the report in File->Summary Info. This will help other
people understand what you did for the report, and it also allows you to use the values
you put in the Summary Info as special fields.