Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Wrox Professional Crystal Reports for Visual Studio NET Second Edition phần 3 ppsx
Nội dung xem thử
Mô tả chi tiết
02 557300 Ch02.qxd 3/24/04 9:24 AM Page 54
Chapter 2
Special Field Name Description
Record Number An internal, sequential record number assigned to all records
returned to the report
Page Number Page number
Group Number An internal, sequential number assigned to all groups
Total Page Count The total page count
Report Title The report title, as saved in the report file’s Summary
Information
Report Comments The comments entered in the Summary Information
Record Selection Formula The Record Selection Formula used by the report
Group Selection Formula The group selection formula used by the report
File Path and Name The full path and filename of the report file
File Author The author of the report from the report file’s Summary
Information
File Creation Date The date the report file was created
Page N of M Where N is the current page and M is the total page count
Summary Fields
Earlier in the chapter, we looked at creating a report using the Standard Expert. One of the tabs in the
expert was for Total, where a summary field could be inserted into your report. Summary fields are
usually associated with groups or a grand total in your report and can be inserted into your report by
right-clicking anywhere within the Report Designer and selecting Insert → Summary from the menu
that appears. This opens the dialog shown in Figure 2-27.
At this point, you may also notice that the right-click menu includes an option for Subtotal; subtotals
and summary fields are similar, but a subtotal refers specifically to a sum, whereas a summary field
could be a sum, an average, or a standard deviation.
Formula Fields
Crystal Reports .NET features a rich formula language that has evolved over the years as a powerful
way to add complex calculations to reports. Formula fields appear in curly braces and are prefixed by
the @ symbol; a formula used within another formula would look like this:
{@SalesTax} + {@InvoiceTotal}
Formula fields are created using the integrated Formula Editor. To see the editor, right-click Formula
Fields in the Field Explorer, select New, enter a name, and then click OK to open the dialog shown in
Figure 2-28.
54
02 557300 Ch02.qxd 3/24/04 9:24 AM Page 55
Getting Started with Crystal Reports .NET
Figure 2-27
Figure 2-28
55
02 557300 Ch02.qxd 3/24/04 9:24 AM Page 56
Chapter 2
When working with formula fields, you have a choice of two different types of syntax: Crystal Syntax or
Basic Syntax. If you have worked with Crystal Reports before, you will probably be familiar with Crystal
Syntax. It was the original formula language available with Crystal Reports and is still used for Record
Selection Formulas and conditional formatting.
Basic Syntax was introduced to eliminate the need to learn a second formula syntax. The syntax, functions, and control structures are similar to Visual Basic, which many developers are familiar with, and it
is easy for developers to create formulas using a language that is familiar to them.
Which language you use depends on what facet of Crystal Reports you are working with. As I mentioned
earlier, the record and group selection formulas within Crystal Reports are written using Crystal Syntax
exclusively, so you are going to have to learn a little bit anyway. For formulas that will appear on your
report, you have a choice of using either Crystal or Basic Syntax. (You can’t mix the two in one formula,
but you can mix the two different types of formulas in one report.) A drop-down list in the Formula
Editor controls the syntax, and you can switch between the two if required.
Formulas are covered in length in Chapter 8, “Formulas and Logic,” but keep in mind you may see
the Formula Editor appear in other places throughout this book; it is also used to create Record Selection
Formulas and perform conditional formatting, among other things.
Parameter Fields
Parameter fields within Crystal Reports .NET are used to prompt the user to enter information when the
report is run. Parameters can be used in a number of different ways, from simple data entry (like entering the name of a user to be displayed on the report) to record selection (to filter the content of a report).
Parameter fields are designated using curly braces and are prefixed by a question mark, so a parameter
field in use in a formula might look something like this:
If {?EnterCountry} = “USA” then “North America”
To insert a parameter field into your report, right-click the Parameter Fields section of the Field Explorer
and select New, which will open the dialog shown in Figure 2-29.
Figure 2-29
56