Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
76
Добавлен:
11.05.2015
Размер:
8.74 Mб
Скачать

HANDS-ON (Multiple Section Reports)

How to prevent variable length objects from overwriting each other

When subreports or other variable length objects are placed above other objects in one section of the report while the Can Grow option for the variable length object is toggled on in the Format Editor, that object may overprint objects positioned directly below it unless you have:

expanded the section to fit the maximum size of the object, and

spaced the objects, allowing enough space for the first object to complete printing before the second one begins. See Types of formatting properties, Page 211.

You can eliminate this overprinting problem by creating multiple sections in an area and placing objects below the variable length object in their own section(s).

Now, when the report runs, the section with the variable length object will finish printing before the section below it prints and you will get the results you want. See FOR TWO UNRELATED REPORTS, Page 425.

NOTE: Memo and BLOB fields, as well as subreports, can cause overprinting.

How to work with text objects

You will use many of the capabilities of text objects when creating form letters. A brief discussion of text objects should make it easier for you to create the form letter in the next section.

Multiple Section Reports

197

Move/Resize mode

Edit mode

A text object can contain both text and fields; you will use both in this example.

You can resize text objects; you will be resizing the text object so that it prints as a letter.

Text objects operate in two modes:

1.the move/resize mode, and

2.the edit mode.

When the object is in the move/resize mode, it appears as a broken line frame with resizing handles.

In this mode, you can resize the object by dragging any of the resizing handles, or you can move it by placing the cursor inside the object and dragging it to a new location. You can also insert fields in this mode, but you can not insert text. You put a text object into the move/resize mode in one of two ways:

1.by clicking the text object when it is inactive, or

2.by clicking the frame when the object is in edit mode.

When the object is in the edit mode, it appears as a broken line frame without sizing handles, and an in-place ruler appears at the top of the tab.

When you first place a text object, the program sets it in the edit mode. You can also put a text object into the edit mode by double-clicking it if it’s inactive or in the move/resize mode.

Each text object contains word processor capabilities, including the ability to change the fonts for individual characters and fields, and automatic word wrap. In the edit mode you can insert text and such nontext objects as database fields and formulas. Whenever the object is in edit mode, it contains an insertion point, a flashing vertical line that indicates the position at which typed text or inserted fields will begin.

The insertion point moves as you type, automatically staying to the right of the last character. It also moves when you insert a field, automatically staying to the right of the field. It moves one character position at a time when you press the space bar. It moves down one line, to the inside left edge of the text object, when you press Enter. It moves to your cursor position when you click anywhere within the existing text.

198

Seagate Crystal Reports User’s Guide

As you work through the tutorials for multiple sections, it is always expected that you will type or place fields at the existing insertion point, unless otherwise indicated.

To select text within a text object (to delete it, to change a font, etc.), position the cursor over the text and, when the I-beam cursor appears, drag the cursor to highlight the text you want to select. See Cursors, Page 54.

To select a field which is inside a text object, position the cursor over the field and, when the I-beam cursor appears, right-click.

To insert text, type in the desired text and it will appear at the insertion point.

NOTE: It is critical that you see the drag and drop cursor before placing the field. If it does not appear, you might place the field so that it overlays the text object instead of being inserted into it. It may appear to be inside the text object, but if you move the object the field will not move with it.

The insertion point is tied into the drag and drop cursor. If you have existing text or fields in the text object, the insertion point moves as you move the drag and drop cursor, enabling you to pick the exact position where you want to place the field. The program always places the field at the insertion point.

As you move the drop cursor...

the insertion point moves.

Related Topics

How to insert text objects, Page 108

Multiple Section Reports

199

How to create a form letter using a text object

Creating the form letter

While form letters themselves are not necessarily multi-section reports, they are often used in multi-section reports to generate custom mailings. The topic How to print conditional messages in form letters, Page 205, explains how to use multiple form letters or multiple versions of the same form letter for custom mailings. The following section shows you how to create a form letter.

You are going to use a text object to create a form letter. The form letter you create will be tied to a database table so that each letter will be customized with company information from a different record.

If you have difficulty performing any of the steps in this tutorial, please see How to work with text objects, Page 197.

The letter will consist of a date, an inside address, a salutation, a one paragraph letter body, and a closing section.

1Create a report using the Customer Table of xtreme.mdb. The Design Tab appears with the Database Tab active in the Insert Fields dialog box.

2Since you do not want field titles to appear above the fields that you insert into the letter, toggle the Insert Detail Field Titles option off on the Layout Tab of the Options dialog box.

3Insert a text object into the Details section of the report.

4Click the text object frame to put the object in move/resize mode.

5Drag the resizing handle on the right side of the object to the right edge of the Design Tab. This will make the object about eight inches wide, the approximate width of a page. You may have to stop resizing, scroll the window, and resize some more to accomplish this.

200

Seagate Crystal Reports User’s Guide

6Double-click inside the text object to place it in edit mode. It is now ready for you to begin your work. The insertion point appears at the extreme left, inside the object.

DATE

1To insert a date into the letter, select the PrintDate field on the Others Tab of the Insert Fields dialog box, drag the placement frame into the text object, and place it at the insertion point.

NOTE: To change the way the date is formatted in the letter, first click the border of the text object to put it in move/resize mode, right-click the PrintDate field, choose FORMAT [PRINTDATE] from the shortcut menu that appears, and make your modifications on the Date Tab of the Format Editor when it appears.

2Press Enter twice to insert some white space between the date and the inside address and to move the insertion point down within the text object.

Multiple Section Reports

201

INSIDE ADDRESS

To create the inside address, drag database fields into the text object from the Customer table on the Database Tab of the Insert Fields dialog box.

1Drag in the Address 1 field and place it at the insertion point, and press ENTER. The insertion point moves down to the line below.

2Drag in the City field and place it at the insertion point.

3Type a comma, followed by a space.

4Drag in the Region field and place it at the insertion point.

5Type in two spaces.

6Finally, drag in the Postal Code field, place it at the insertion point, and press ENTER. The insertion point moves down to the line below.

7Press Enter one more time to move the insertion point down one more line to the position where the salutation should start. This completes the inside address.

NOTE: When a field is placed within a text object, it is automatically trimmed on both the left and right sides, so that it contains no extra white space.

SALUTATION

1Press ENTER four times to move the insertion point down.

2Type in the word “Dear” and a space (do not include the quotation marks).

202

Seagate Crystal Reports User’s Guide

3From the Insert Fields dialog box, highlight the Contact Title field from the Customer table and drag it into the text object, placing it immediately after the space.

4Type a space. The program positions the insertion point immediately after the space.

5Again from the Insert Fields dialog box, drag the Contact Last Name field into the text object and place it at the insertion point. The insertion point moves to the right of the field.

6Type a colon “:” at the insertion point (without the quotation marks) and press ENTER to move the insertion point to the next line.

LETTER BODY

1Now type “Your company” (do not include the quotation marks) and type a comma followed by a space.

2Drag the Customer Name field into the text object and place it at the insertion point, just after the space.

3Type a comma, followed by a space.

4Type the following text (do not include the quotation marks): “helped make 1996 an outstanding year for Xtreme Mountain Bikes, Inc. I want to thank you and your staff for your support. I hope 1997 will be a banner year for you.”

5Press ENTER twice.

6Type “Sincerely yours” (without the quotation marks), followed by a comma, and then press ENTER four times.

7Finally, to complete the form letter, type your name.

Multiple Section Reports

203

The Design Tab should look similar to this:

8Click the PRINT PREVIEW button on the standard toolbar to preview the form letter.

It should look similar to this:

How to format objects conditionally

You may want to create a report that uses different formats depending on the field value. For example, you may want to create an international report that prints currency values for each country in the format that is common in that country. You can do that using multiple sections.

204

Seagate Crystal Reports User’s Guide

1Create a report. See Tutorial - Customer List, Page 147, and Introduction to Reporting, Page 85.

2Create one Details section for each country that requires a unique format. See How to add, delete, and move guidelines, Page 72.

3Make certain that each of the Details sections contains the same data; every field that you place in the Details A section, you must also place in the Details B section, and in the Details C section, etc.

4In the Details A section, select the currency field and then click the OBJECT PROPERTIES button on the supplementary toolbar. The Format Editor appears.

5Set the currency values you want to use for the first country. See

Formatting, Page 209.

6Click OK to return to the report.

7Click the SECTION EXPERT button on the standard toolbar. The Section Expert appears.

8Select the Details A section in the Sections list box. Toggle the

Suppress (No Drill-Down) check box on.

9Click the Conditional Formula button to the right of the Suppress check box and use the Format Formula Editor to create a formula that specifies the conditions under which the section should be suppressed.

For example, if the Details A section contains currency values for the UK, you would create a formula that specifies that the country value is not equal to UK. In other words, you create a formula that suppresses the section when the country value is not UK. This will make the section print only when the record contained a UK value.

10Repeat Steps 4 through 9 for each additional section.

Now, when the report is printed, the date and currency data for each country appears in the format that is expected for that country. See

Conditional formatting, Page 212.

How to print conditional messages in form letters

It is likely that you will want to print conditional messages in form letters. For example, you may want to encourage customers with available credit to buy more and those who are over their credit limit to bring their accounts down below the limit once again. You can create both of these letters within a single report.

Multiple Section Reports

205

1Use the Section Expert to insert a second Details section in the report. See How to add, delete, move, and merge sections, Page 79.

2Create two form letters. Place a letter that encourages customers to buy more in the Details A section of the report; place a letter that encourages customers to bring their balance down in the Details B section of the report. See How to create a form letter using a text object, Page 200.

3Use the Section Expert to format the Details sections so that each is suppressed under certain conditions. For example:

Format this section to be suppressed when the balance is less than the credit limit.

Format this section to be suppressed when the balance is more than the credit limit.

Now, when a record indicates available credit, the buy more letter will print. When the account is over limit the over limit letter will print. And when the customer is right at the credit limit, nothing will print at all.

Related Topics

How to format objects conditionally, Page 204

Conditional formatting, Page 212

How to alternate background colors for rows

Another typical use of multiple sections is to vary the background color in alternating lines for the Details section of your report in order to improve readability (a greenbar-paper effect).

1Use the Section Expert to insert a second Details section. You should now have Details A and Details B sections. See How to add, delete, move, and merge sections, Page 79.

2While in the Section Expert, highlight Details A in the Sections list box, click the Color Tab, and set the background color to White. See

Formatting, Page 209.

206

Seagate Crystal Reports User’s Guide

3Click the Common Tab, click the Conditional Formula button to the right of the Suppress (No Drill Down) option, and type the following formula in the Format Formula Editor when it appears:

Remainder (RecordNumber,2)<>0

«This formula divides the record number by 2 and if the remainder is something other than zero (which will happen for every odd numbered record), it tells the program to suppress the section.»

Search for Formula Compiler Errors in Seagate Crystal Reports online Help.

4Now select Details B and set the background color to Green.

5Use the technique from Step 3 to set the Suppress option conditionally for this section using the following formula:

Remainder(RecordNumber,2) = 0

«This formula divides the record number by 2 and if the remainder is equal to zero, it tells the program to suppress the section.»

6Create the report and make certain that the information and layout of each of the Details sections is identical. In other words, whatever objects you put in Details A should be put into Details B as well.

Now when you run the report, the program will print every even numbered line with a white background and every odd numbered line with a green background.

How to eliminate blank lines

It is very common to have two address lines in a customer table, one (Address 1) for street address and one (Address 2) that can be used for a suite number or mail stop. Address 1 usually contains a value but Address 2 is often blank. If you create a customer list using this data and stack the fields on top of one another in mailing label format, those customer records with an empty Address 2 field will print with a blank line. You can eliminate this blank line using multiple sections.

1Use the Section Expert to create two new Details sections so that you have a total of three. See How to add, delete, move, and merge sections, Page 79.

2Place the Address 2 field in the middle section and the other data in the sections above and below it as you want it to appear in the report.

3Format the middle section to Suppress Blank Section. See How to hide parts of a report, Page 114.

Multiple Section Reports

207

Now, when the report prints, if the Address 2 section is blank, the program will not print it and you will not get unwanted blank lines in the report.

Before suppressing blank lines, the Address2 field prints a blank line if it is empty.

After suppressing blank lines, the Address2 field does not print if it is empty.

How to add blank lines conditionally

Use multiple sections to print a blank line on your report under specific conditions. For example, you may want to insert a blank line after every fifth record in the report.

1Create two Details sections. See How to add, delete, move, and merge sections, Page 79.

2Put the report detail data in the top section.

3Leave the second section empty.

4Format the second section to be suppressed unless the following condition is met:

Remainder (RecordNumber,5) <> 0

«This formula divides each record number by 5. If the division produces a remainder, it suppresses the blank section. But if the division produces no remainder, a zero (which it will for every fifth record printed), the program prints the second section, thus inserting a blank line.»

NOTE: To insert a blank line under different conditions, you can modify your formula appropriately. See Conditional formatting, Page 212.

208

Seagate Crystal Reports User’s Guide

10 Formatting

What you will find in this chapter...

Formatting concepts, Page 210

Absolute formatting, Page 211

Types of formatting properties, Page 211

Conditional formatting, Page 212

HANDS-ON (Absolute Formatting), Page 215

HANDS-ON (Conditional Formatting), Page 221

Formatting

209

Formatting concepts

In this section, you will learn about formatting a report. Formatting refers to those things that are done to change the layout and design of a report, as well as the appearance of text, objects, or entire report sections.

You can use formatting to do many things, including:

divide sections of a report,

call attention to certain data,

change the presentation of dates, numbers, Boolean values, currency values, and text (strings),

hide unwanted sections, or

give the report a professional appearance.

Seagate Crystal Reports offers a wide range of formatting commands and properties which can be applied to various elements of a report.

Use formatting commands by choosing or setting options in dialog boxes that are specific to the kind of formatting you are doing. For example, to change page margins, use a dialog box that allows you to specify the top, bottom, right, and left margins.

Set formatting properties in either the Format Editor (for objects) or the Section Expert (for sections) by toggling check boxes on and off or by supplying attribute values. In most cases, you can set one of two types of properties:

¾Absolute (always apply the property), or

¾Conditional (apply the property only if certain criteria are met).

You can use both kinds of formatting properties wherever you need them in the report. See Absolute formatting, Page 211, and Conditional formatting, Page 212.

In the topics that follow, you will learn about the kinds of formatting you can do with Seagate Crystal Reports, and you will get step-by-step instructions for performing a variety of formatting tasks.

NOTE: There are many date formats you can choose to use in your English report, but if you send the report to a Japanese system, there may be some formatting irregularities. Not all English date formats are viewable on a Japanese system, and the same is true going from Japanese to English. For more information, see Japanese Dates in Seagate Crystal Reports online Help.

210

Seagate Crystal Reports User’s Guide

Absolute formatting

Absolute formatting is formatting that applies under any condition.

SELECT, THEN APPLY

Absolute formatting always follows a select, then apply procedure:

you select what it is that you want to format (an object or a section), and then

you apply the formatting to the selection using property settings. Use the following dialog boxes for formatting reports:

Format Editor for formatting field values.

¾Borders Tab for formatting objects, numbers, and text,

¾Box Tab for formatting boxes, and

¾Line Tab for formatting lines.

Section Expert for formatting entire sections.

Highlighting Expert for formatting currency and number fields.

Each of these dialog boxes contains a number of different formatting properties as well as the tools for turning the properties on or off, or for specifying attributes. Search for the dialog box by name in Seagate Crystal Reports online Help.

Types of formatting properties

Formatting properties fall into two general categories:

1.On or Off Properties, and

2.Attribute Properties.

ON OR OFF PROPERTIES

An on or off property is a property that is set using a check box.

When this check box is toggled on, the property is always applied.

When this check box is toggled off, the property is never applied. The Suppress property is one such on or off property; an object or section

Formatting

211

is either suppressed (on) or it is not (off).

ATTRIBUTE PROPERTIES

An attribute property is a property that specifies one of many possible attributes. The Color property, for example, gives you the opportunity to specify one of the 16 basic Windows colors or a custom color and then to create that color using the tools provided. Clearly such a property cannot be handled with a simple on or off switch.

You set an attribute property in one of several ways, depending on the property. You can set it:

by clicking an option button,

by selecting an attribute from a drop-down list,

or, by typing an attribute in a text box.

Conditional formatting

Conditional formatting is formatting that applies only under certain conditions. For example, in a report you may only want:

customer balances printed in red if they are past due,

212

Seagate Crystal Reports User’s Guide

Conditional on or off properties

Conditional attribute properties

the dates to appear in Day, Month, Year format if the customer is Canadian, or

background color to appear on every other line.

Seagate Crystal Reports makes it easy to apply formatting conditionally in these and hundreds of other situations. See How to format objects conditionally, Page 204.

With absolute formatting you follow the select, then apply procedure. For conditional formatting you follow the same general procedure, but you go a step further and set up conditions that determine whether or not the formatting will be applied. You specify these conditions using simple formulas. See Introduction to Formulas, Page 291.

NOTE: When you set up a conditional formatting formula, the formula overrides any fixed settings you have made in the Format Editor. For example, if you toggle the Suppress option on and then set up a conditional formula for the Suppress option, the property will still apply only if the condition in the formula is met.

The program enables you to set both on and off properties and set attribute properties conditionally. However, each of these requires a different kind of formula.

A conditional on or off property tests to see if a condition has been met. It is on if the condition is met, off if the condition is not met. There is no middle ground. Use Boolean formulas for this kind of formatting.

Value = condition

The program tests each value to see if it meets the condition and it returns a yes or no answer. It then applies the property to every value that returns a yes answer.

A conditional attribute property tests to see which of two or more conditions is met. The program then applies the formatting appropriate to the condition. For example, assume that you want values under quota printed in red and all other values printed in black. The program tests to see whether the value is under quota or not. If it is under quota, then it applies the red attribute; if it is not, then it applies the black attribute.

Use an If-Then-Else formula for this kind of conditional formatting. See

How to create If-Then-Else formulas, Page 316.

If Condition A Then

Red

Else

Black

Formatting

213

Values that do not fit any condition

NOTE: When conditional attribute properties are set up, the program loads a selection of attributes into the Functions list in the Formula Editor. Double-click any of these attributes to add them to your formula. For example, if you are setting horizontal alignment conditionally, the Functions list box will contain attributes such as DefaultHorAligned, LeftAligned, Justified, etc. If you are setting borders conditionally, the Functions list box will contain attributes such as NoLine, SingleLine, DashedLine, etc.

You can take this kind of property one step further. You can specify a list of conditions and a property for each; you are not limited to two conditions. For example, if you have a number field on your report that contains sales figures from countries around the world, you can specify the number attribute(s) that you want to apply to each country. In this case, your conditions would specify that if it is from Country A, the program should apply the Country A attribute; if it is from Country B, the Country B attribute; if it is from Country C, the Country C attribute, and so on.

With more than two alternatives, use this kind of formula:

If Condition A Then

Red

Else If Condition B Then

Black

Else If Condition C Then

Green

Else

Blue

Use a multi-condition If-Then-Else formula for this kind of conditional formatting. See How to create multi-condition If-Then-Else formulas, Page 317.

With conditional on or off properties, values will either meet the condition you set or they will not. But conditional attribute properties are different. There may be some cases in which values do not fit any of the conditions set up.

For example, if you set:

all sales figures that are more than 10% over quota to appear green, and

all sales figures that are less than 10% over quota to appear red,

what is going to happen to values that are exactly 10%? The program takes care of that automatically. When a value does not fit any of the conditions in the formula (in this example, all values that are 10%), the program formats that value using the attribute setting in the dialog box.

214

Seagate Crystal Reports User’s Guide

Соседние файлы в папке crystal