Using the Blank Report Option


While the report wizards simplify the report design process by presenting a step-by-step approach, they limit your flexibility to create a report exactly as you d like it to look. You are required to accept the fonts, colors, and layout that the wizard chooses. Group total and summary fields are labeled haphazardly, and group fields are repeated over and over again in every report line within the group .

Although it s initially more labor- intensive , using the Blank Report option to create a report gives you absolute control over what you put on your report, where you put it, and how it looks. Even if you use the report wizards, it s important to understand the concepts involved in the Blank Report option, because you ll want to use those concepts to refine most reports that the report wizards create. To use the Blank Report option, click the As a Blank Report radio button on the Report Gallery dialog box when first creating a new report. Then click OK. The Database Expert will appear.

The Database Expert

The Database Expert, shown in Figure 1-3, is where you choose the database tables you wish to include in your report. Here, you can select from any database type that Crystal Reports supports, including PC-type local databases, such as Microsoft Access, dBASE, Paradox, Btrieve, and others. You can also choose from virtually all popular client/server or SQL databases, such as Microsoft SQL Server, Oracle, Informix, and Sybase. Crystal Reports even supports proprietary data types, such as web server activity logs, the Windows NT/2000 event log, Microsoft Exchange systems, and XML-formatted data. These data types are all chosen here.

click to expand
Figure 1-3: The Database Expert

The Database Expert categorizes types of databases, shown as small folder icons with plus signs next to them. Depending on the type of database you want to report on, click the plus sign next to one of the following database categories:

  • Current Connections Displays a list of any databases you may already have connected to when working with previous reports. These connections will be closed when you close Crystal Reports.

  • Favorites Contains data sources that you ve previously added to your Favorites folder ”if you use a data source on a regular basis, you may want to add it to the Favorites category to make it easy to find.

  • History Shows data sources that you ve recently connected to.

  • Create New Connection Displays another set of subcategories that show types of databases that Crystal Reports will connect to. The folders that appear here are based on what database connection options you chose when you installed Crystal Reports, as well as on database connection software you may have installed on your computer, such as an existing program that contains an Oracle or DB2 client database driver.

  • Repository Requests Crystal Enterprise logon info , then displays a list of any database connections that you have added to the Crystal Enterprise 10 Repository (the Repository is covered in more detail in Chapter 7).

After you click the plus sign next to the category you wish to use, you may see a list of available databases under that category. If you re already logged on to a database in that category, you ll see the database name and all the available tables underneath the database name . Choose the desired database or subcategory . Depending on the category or database you choose, additional dialog boxes will appear, asking you to choose a particular database filename, log in to the database, or choose a database server. Eventually, you ll be able to choose one or more database tables that you wish to include in your report. You may also see a selection of database object types such as tables, views, and stored procedures that you can choose from. Click the plus sign next to the desired object type and choose an object from within the category.

To add a table to the report, select the table and click the right-arrow button. You can also just double-click the table name. When the table has been added to the report, the table name will appear in the rightmost Selected Tables list. If you add a table by mistake, just select it and click the left-arrow button to remove it ”it will disappear from the Selected Tables list. If you want to select and add multiple tables at a time, you may multi-select additional tables by holding down the CTRL key while clicking table names . Or, you may SHIFT -click on two tables to select those two tables, as well as all tables in between. When you ve chosen the tables you want to add to the report, click the right-arrow button to add them all at once. And, finally, you may simply add all tables in the Available Data Source list to the Selected Tables list by clicking the double-right-arrow key. Once you ve selected all the tables you want to include in your report, close the Database Expert with the Close button.

Tip  

There may be several different ways of connecting to the same database. If, for example, you wish to report on a corporate Oracle database, you may connect via ODBC, via OLE DB, or by using a Crystal Reports native driver in the More Data Sources category within Create New Connection. If you re unsure of how to connect to your database, check with your database administrator.

If you choose more than one table for your report, a Links tab will appear in the Database Explorer. You must click this tab to link the tables you ve added to your report together. If you don t link tables, you ll be presented with the Links tab when you click OK on the Database Explorer dialog box. Use the Links tab to join or link your tables together. Table linking is discussed in detail in Chapter 16.

The Design Tab and Field Explorer

Once you ve chosen and linked tables, Crystal Reports will display the Design tab. This is the template view that you use to begin designing the look and feel for your report. The first step to beginning report design is choosing fields for the report from the Field Explorer , shown in Figure 1-4. If you don t already see the Field Explorer, you can display it by clicking the Field Explorer button in the Standard Toolbar, or by choosing View Field Explorer from the pull-down menus . Begin designing your report simply by dragging fields from the Field Explorer and dropping them on the report where you want them to appear.

click to expand
Figure 1-4: The Design Tab and Field Explorer

The Field Explorer contains categories of fields that are available to place on your report. You ll see a plus sign next to the Database Fields category, indicating that more choices are available in that category. Clicking the plus sign next to it will expand the category, showing all the tables you added from the Database Expert. Plus signs next to the table names, as well as next to the Special Fields category, indicate that fields are available below those levels ” click the plus sign to see available fields. The other categories of the Field Explorer will not have any plus signs next to them, unless you ve opened an existing report that already contains fields of these types. Once you begin creating new formulas, parameter fields, and so on, you ll see plus signs next to these categories as well. Click the plus signs to see available fields in these other categories.

The simplest way to add a field to the report is to drag and drop the field from the Field Explorer to the report s Design tab. When you drag, you ll see an outline of the field object appear on the report as you drag. When you have positioned the field where you want it to appear, simply release the mouse button to drop the field on the report. As an alternative, you may right-click a field and choose Insert to Report from the pop-up menu, select the desired field, and click the Insert to Report button (the first toolbar button) from the Field Explorer toolbar, or just press ENTER . The field will be attached to the mouse cursor, which you can then position to drop the field.

You re not limited to dragging and dropping one field at a time to the report. If you see several fields you d like to drag and drop at once, use CTRL- click to select or deselect multiple fields. If you wish to select a range of fields, click the first field in the range and then hold down the SHIFT key and click the last field in the range. Both fields, as well as all of those in between, will be selected. After you CTRL- or SHIFT- click the desired fields, drag and drop them as a group. After you add a field to the report, you see a small green checkmark next to the field in the Field Explorer. This indicates that the field is in use somewhere on the report.

Tip  

You do not have to leave the Field Explorer docked to the side of the Crystal Reports window. If you d like to expand the size of the Design tab so you have more room to work without scrolling, undock the Field Explorer by pointing to its title bar area at the top. Then, drag the Field Explorer away until you see the outline of a separate free-floating window. The Design tab will expand to the full width of the Crystal Reports window, and the Field Explorer will now display in its own free-floating window. To redock the Field Explorer, drag it back toward the edge of the Crystal Reports window until the outline of a docked window again appears. You can redock the Field Explorer to the left, bottom, or right of the Design tab.

Report Sections

When you first create a new report, Crystal Reports shows five default sections in the Design tab. Table 1-1 outlines where and how many times each section appears in a report, and the types of objects you may want to place in them.

Table 1-1: Default Report Sections

Section

Where It Appears

What to Place in the Section

Report header

Once only, at the beginning of the report

Title page, company logo, introductory information that you want to appear once only at the beginning of the report, charts or cross-tabs that apply to the whole report

Page header

At the top of every page

Field titles, print date/time, report title

Details

Every time a new record is read from the database

Database fields and formulas that you want to appear for every record

Report footer

Once only, at the end of the report

Grand totals, closing disclaimers, charts, or cross-tabs that apply to the whole report

Page footer

At the bottom of every page

Page numbers , report name, explanations for figures in the report

If you drag a database field into the details section, Crystal Reports places a field heading in the page header automatically and aligns it with the database field. If you drag a database field into any other section, no field heading will be inserted, even if you drag the field into the details section later ”automatic field headings are only created if you drag a field directly into the details section (and, if you haven t turned off the Insert Detail Field Headings option in File Options).

Previewing the Report

When you see objects depicted in the Design tab, Crystal Reports is only displaying placeholders. You ll see the names of fields and objects surrounded by outline symbols, indicating how wide and tall they are. You won t ever see actual data in the Design tab. To see the report containing real data as it might appear when printed on a printer or exported to a web page, you need to preview the report.

There are several ways of previewing a report. Choose File Print Preview or click the Print Preview button on the Standard toolbar to preview the entire report. To preview a limited number of records, choose File Print Preview Sample and specify the number of records you wish to see.

When you preview a report, the Preview tab appears next to the Design tab, as shown in Figure 1-5. You can scroll up and down through the report, use the Zoom control to change the Zoom level of the report, and use the page navigation buttons to move through various pages of the report. You can easily move back and forth between the Design and Preview tabs by clicking them.

click to expand
Figure 1-5: Previewing a report

Moving and Sizing Objects

Once you ve placed objects on your report, you will probably want to move them around the report as your design progresses. Crystal Reports estimates how much horizontal space is required to display string database fields. This may result in string fields on the report that may appear too narrow or too wide. Also, if you change the font size of an object, you ll usually have to adjust the object size accordingly .

The first step in moving or sizing an object is to select the object. Simply click it. A shaded outline and four blocks appear around the object, indicating that it is selected. Now you can move or size it.

Pointing inside the selected object causes your mouse pointer to turn into a four-way pointer. You can then click and drag the object to a new location with the mouse. If you point at one of the little blue blocks ”the sizing handles at the top, bottom, left, and right of the object ”your mouse pointer turns into a two-way size pointer. Clicking and dragging these handles stretches or shrinks the object. Sizing objects requires very precise accuracy with your mouse! Laptop users with trackpads will probably opt for an external mouse after trying this a few times.

You re not limited to moving or sizing one object at a time. You can select multiple objects before moving or sizing them. CTRL -click or SHIFT -click to select more than one field or field title. You can also surround multiple objects with an elastic box. Before you start to draw the elastic box, make sure you deselect any already selected objects by clicking an area of the report where there are no objects.

Tip  

When the Design tab is displayed, you don t have to use the mouse to move or resize objects. For very fine control of object placement and sizing, use your keyboard s cursor keys. Using the cursor keys by themselves will move selected objects in the direction of the key. If you hold down SHIFT and use the cursor keys, objects will be widened, narrowed, made taller, or made shorter in the direction of the keys.

Using Guidelines to Move Objects

When you insert a database field into the details section, Crystal Reports inserts two other things automatically. The first, the field heading, appears directly above the field in the page header. What might not be so obvious is the vertical guideline. You ll notice a little upside- down tent (officially known as a guideline handle ) in the ruler above the report. The guideline is actually a vertical line extending from the guideline handle all the way down the report. Crystal Reports automatically placed this in the ruler, and it attached the field in the details section and the field heading in the page header to the guideline.

Note  

By default, only the guideline handles are visible when you first install Crystal Reports. If you d like to see the dashed guidelines in the Design tab, choose View Guidelines Design from the pull-down menus. To see guidelines in the Preview tab, choose View Guidelines Preview from the pull-down menus. Note that even if you make the latter choice, you ll only see the dashed guidelines in the Preview tab if you click any object to select it in the preview window.

You may move objects as a group by dragging the guideline handle left or right inside the ruler. All objects attached to that guideline will move at the same time. If you ve placed a database field in the details section and an associated field heading in the page header, and you have inserted several group subtotals in groups and grand totals in the report footer, they will typically all be attached to the same guideline. Just move the guideline left or right to move all the objects together.

click to expand

With a little experience, you ll probably quickly develop a love-hate relationship with guidelines. If you have lots of smaller objects positioned closely together on a report, you ll probably give up on the guidelines and just move them by CTRL -clicking or using an elastic box. If you have fewer objects spaced a little farther apart on your report, or lots of aligned objects in several report sections, you ll probably like using the guidelines to rearrange objects. Table 1-2 shows some of the guideline issues that may crop up in your report-design process, along with ways of solving the problems.

Table 1-2: Guideline Issues

What Happened

How Is It Fixed?

You mistakenly dragged a guideline off the ruler when you just wanted to move it left or right. The objects attached to it haven't moved, and the guideline is now gone.

Click the Undo button on the Standard toolbar, or choose Edit Undo. This will bring the guideline back. If you notice the missing guideline after you've completed other tasks , and you don't want to Undo, just add a guideline back into the ruler by clicking in the ruler; reattach the objects by dragging them to the new guideline.

You selected and moved an individual object or objects with your mouse, but the guideline didn't move with them. Now, when you move the guideline in the ruler, the objects don't move.

You detach an object from a guideline when you move the object in the Design tab. You cannot reattach guidelines to objects by moving the guideline in the ruler. You have to reattach objects to guidelines by moving the objects until they snap to the guidelines. You can tell when an object has been reattached to a guideline by looking at the very small red marks on the edge of the object where it's attached to the guideline.

You've resized or moved objects and they now appear to be attached to two guidelines: one on the left and one on the right. When you move either guideline, the objects stretch rather than move.

Resize the objects away from the guideline you don't want them attached to. By resizing, you detach them from one guideline while leaving them attached to the other.

You notice that when you delete objects from the report, the guidelines stay and clutter up the ruler. When you move other objects around on the report, they're always snapping to the stray guidelines.

Remove any unwanted guidelines simply by dragging them off the ruler.

Note  

If you created the report with a report wizard, you ll see that Crystal Reports inserted horizontal guidelines on the left side of the Design tab. You can add these yourself if you use the Blank Report option. Just click in the side ruler to add a horizontal guideline. Then attach objects to them on the top, bottom, or middle. Move the guideline to move whole lines of objects up or down at the same time.

Formatting Objects

When you place objects on your report, Crystal Reports applies default font faces, sizes, colors, and formatting to the objects. You ll usually want to change some of this formatting to suit your particular report style or standards. There are several ways of formatting objects. As you use Crystal Reports, you may find that one way suits you better than another. Also, all formatting options aren t available with every method, so you may need to use a certain one to perform a specific kind of formatting.

Using the Formatting toolbar is the quickest way to apply standard formatting. The Formatting toolbar is similar to other toolbars you may have used in word processors or spreadsheet programs. To format using the Formatting toolbar, first select the object or objects you want to format, and then change their formatting by clicking Formatting toolbar buttons or choosing items in drop-down lists.

Some formatting options, such as formatting a date field to print in a long date format or designating that only one dollar sign should print at the top of each page, aren t available on the Formatting toolbar. These formatting options, along with all the options available on the Formatting toolbar, can be chosen in the Format Editor, shown in Figure 1-6. To use the Format Editor, first choose the object or objects that you wish to format, and then do one of the following:

  • Click the Format button on the Expert Tools toolbar.

  • Choose Format Field from the Format menu.

  • Right-click the object and choose Format Field from the pop-up menu.

    click to expand
    Figure 1-6: The Format Editor

All of these options display the Format Editor. Choose the desired tab on the Format Editor, and make formatting selections by choosing one of the built-in styles, by using a custom style, or by choosing other specific formatting options on the desired tab. Click OK on the Format Editor to apply all the formatting you chose and close the Format Editor.

There are two general ways you can choose formats in the Format Editor ”with a default style, or by customizing the style. In particular, you ll notice a selection of predefined formats for most non-string data types in the Style list. You can just choose one of these default formats from the list. If, however, the exact format you want isn t in the Style list, click the Customize button at the bottom of the Style list. A Custom Style dialog box will appear where you can make more detailed choices about how to format the field. You ll need to use the Customize button to conditionally format some aspects of the field as well (conditional formatting is discussed in Chapter 9).

click to expand
Tip  

You can add new objects, or move, size, and format existing objects, just as easily in the Preview tab as in the Design tab. Be careful, though, that you move or size objects accurately in the Preview tab. You may inadvertently move an object from the details section to the page header, or make some similar undesirable move, without realizing it. Formatting objects in the Preview tab is great, but it may be better to size or move them in the Design tab.

Customizing Crystal Reports Behavior

When you first install Crystal Reports, it behaves in a certain way that should serve most report designers well. However, you will probably want to customize the behavior of some Crystal Report options. Other software typically has a Preferences or Options menu item to accomplish this. Crystal Reports has two options that work together to control how the program behaves: Options and Report Options, both chosen from the File menu.

Most often, you will use the Options dialog box, shown in Figure 1-7, to change the default behavior of Crystal Reports. For example, to change the default font face and size from Times Roman 10 point to something else, you would click the Fonts tab in the Options dialog box, click the button for the type of object you want to change, and choose a different font or size. To change the default format of date fields from mm/dd/yy to mm/dd/yyyy, you would click the Fields tab in the Options dialog box and then click the Date button.

click to expand
Figure 1-7: Options dialog box
Caution  

Many options you choose here don t change items already placed on the current report, or any existing reports ”they will only affect new items added to the report. For example, if you change the default font to 8-point Times New Roman, only new objects that you add to the report from that point forward will take on that new formatting.

There are a number of options that benefit the new user and make report creation a bit easier. You may want to choose File Options and set each of the following options to your own personal preference.

The Options dialog box is divided into a series of tabs, each categorizing the various options that are available. What follows is a summary of the more often chosen options.

Layout Tab

  • Design View ”Guidelines You may wish to turn this option on to display dashed guidelines in the Design tab. The majority of report designing should occur in the Design tab, and guidelines can be useful.

  • Design View ”Short Section Names Once you re more familiar with the Design tab, you may turn this option on to give you more design area. This will change the fully spelled section names at the left of the Design tab to smaller abbreviations.

  • Preview ”Section Names You ll probably want to leave this option in to help you troubleshoot sectional problems when you re in preview mode. This will show abbreviated section names to the left of the Preview tab.

  • Grid Options ”Snap to Grid Great to turn off when you want to be able to truly use freeform placement of objects. This will allow precise placement without objects snapping to the predetermined grid.

  • Design View ”Grid If you leave Snap to Grid turned on, this will actually show the grid in the Design tab as a series of dots, so you can see exactly where objects you are moving will snap.

  • Preview ”Grid You ll probably want to leave this option turned off to improve clarity. You may turn it on if you are moving and resizing objects in the Preview tab and want to see where they will snap.

Reporting Tab

  • Save Data with Report Checks the File Save Data with Report option automatically when you create a new report. This saves data in the Preview tab along with the report design in the report .RPT file. If you don t want this option turned on when you create a new report, uncheck it here in File Options.

  • Suppress Printing if No Records Selected If the particular combination of data and record selection chosen returns no records, this option will suppress printing of every object on the report. If you leave this option turned off and no records are returned, text objects in page/report headers, and other fixed objects, will still print.

  • Show All Headers on Drill Down Shows all headers above the group being drilled into inside the drill-down tab. See Chapter 10 for information on drill- down reporting.

  • Autosave Reports after x Minutes This will automatically save your report files every few minutes, preventing a loss of data if you suffer a power failure or your computer hangs . You may choose how often to automatically save reports. Reports are saved in the drive/folder specified as your Windows Temp folder with the file extension .AUTOSAVE.RPT.

  • Save Preview Picture This will automatically save a small thumbnail view of your report along with the .RPT file when you save the report (you must preview the report before you save it for the Preview Picture to be saved). This is helpful if you plan on posting the report in Crystal Enterprise (discussed in Part II of the book).

  • Formula Language This feature allows you to choose the default formula language for Crystal Reports formulas. You may change the language used for formulas within each formula, but this allows you to choose the default. Chapter 5 discusses the different formula language options in more detail.

Database Tab

  • Sort Tables Alphabetically/ Sort Fields Alphabetically This will sort tables in the Database Expert and fields in the Field Explorer alphabetically, rather than in the order the database returns them. This may be helpful with large databases when you need to find a particular table or field.

  • Database Server Is Case-Insensitive If you check this option, SQL databases that you use (such as Microsoft SQL Server, Oracle, and Informix) will ignore the case of any record selection you may provide. For example, if you supply a record selection or Select Expert comparison value of USA , the report will still include records if they include Usa , usa , or uSa .

  • Select Distinct Data for Browsing You may notice that browsing for sample data in the Select Expert, in the Field Explorer, and in other parts of Crystal Reports takes a significant amount of time. This is probably because the report is set to Select Distinct Data for Browsing. If you turn off this option, only the first 500 records of the report will be read when browsing, instead of reading records until 500 unique values are retrieved. Although this may not supply as many sample values when browsing, it can be significantly faster.

  • Perform Query Asynchronously Checking this option will allow you to stop a query sent to a SQL database before it begins returning records to the report. You can do this with the Stop button in the Preview tab (the square button to the right of the page navigation buttons). If you leave this option unchecked, you will have to wait until the server completes the query and begins to return records to the report before you may stop report processing.

Fonts/Fields Tabs

These tabs will allow you to choose formatting options for different Crystal Reports data types (such as string, numeric, dates, and so forth) and different types of Crystal Reports objects (such as database fields, summary fields, field titles, and so forth). Click the desired button and choose desired formatting options for the default Format Editor. New objects placed on reports from that point forward will take on the new formatting.

A subset of items from the Options dialog box appears on the File Report Options dialog box.

click to expand

When you create a new report, these options are based on what s set in the File Options dialog box. Later, though, these options can be set to be different than the corresponding File Options dialog box items. When the report is saved, these options are saved along with the report. The next time the report is retrieved, they will supersede the corresponding File Option items.




Crystal Reports 10
Crystal Reports 10: The Complete Reference
ISBN: B005DI80VA
EAN: N/A
Year: 2004
Pages: 223
Authors: George Peck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net