Info

■ ^ Page N of M

I _Unbound Fields

You can also customize the group name field by right-clicking in the group header or footer and selecting Change Group from the right-click menu. Then select the group you want to work with and click Options to open the dialog shown in Figure 3-13.

Figure 3-13

By default, Crystal Reports will automatically create the group name for you based on the field you are grouping on, but you can override this option. In the bottom of the dialog, select the Customize Group Name Field check box. For selecting a new group name, you have two options. If the group name that you want to use is stored in a database table and has a direct relationship to your group field, you can use the drop-down list to select an existing field.

An example of this would be a report that grouped on Product Type and was a reference number (for example, 001, 002, or 003). If you had a lookup table that stored the reference number and the description of the product type (that is, 001 = "Mountain Bikes", 002 = "Racing Bikes"), you could use this table to display a proper name instead of the product type number.

If you don't have a table that stores this information or if you want to do a more complex lookup for the group name, you can select the option immediately below to "Use Formula as Group Name" and then click the X+2 icon to open the formula editor and enter a formula to derive the group name.

For more information on working with formulas, check out Chapter 8, "Formulas and Logic."

This formula should take the format of an if..then statement with the output being the group name itself (for example, if {Customer.Country} = "USA" then "United States"}).

You may also notice there are two additional settings at the bottom of the Change Group Options dialog. The Keep Group Together setting is designed to help eliminate orphaning of groups across multiple pages. (This sometimes works with mixed results.) The second option, Repeat Group Header On Each Page, will repeat the header section of your group on every page of your report. This can be handy for large reports that have multiple pages of the same group; with the group header at the top, you will always know where you are in the report's structure.

And finally, the last formatting option we probably need to look at is how to throw page breaks between groups. You won't find this option on any of the dialogs we have used to create or edit groups. This setting is related to the section formatting options we looked at in Chapter 2 when we had our first look the Section Expert. Right-click either the group header or footer and select Section Expert from the right-click menu to open the dialog shown in Figure 3-14.

Figure 3-14

Select the section where you want to throw the page break and then use the check boxes on the right side of the dialog to select either the New page before or New page after option, depending on your requirements.

Was this article helpful?

0 0

Post a comment