Chapter 4 - Selecting Records with Parameters


This chapter first shows you how to filter data using the Select Expert and then shows you how to create advance filters using parameters. Parameters are covered in great detail because they are also used within report formulas and for custom formatting. The effective use of parameters within record selection formulas and custom formatting lets you create dynamic reports that are tailored to each specific user.

Become a Crystal Reports expert with the authoritative resource available. The tuturials and tips in this book will take your skills to the next level.
Buy at

This is an excerpt from the book Crystal Reports Encyclopedia. Click to read more chapter excerpts.

Creating Parameters

The first part of this chapter showed how filtering data lets you customize a report to fit a specific user's needs. The only drawback to this approach is that you have to know in advance what that user's needs are when you are designing the report. And if different users have different needs, then you either have to save a separate copy of the report for each variation or the user needs to know how to customize the report themselves. Neither of these options is the most practical approach. A much better solution is to create a filter that uses parameters to prompt the user for their input prior to printing the report. This lets you create one report that satisfies many users.

In their most basic form, report parameters are simply a means of asking the user questions about what they want printed. When the user opens the report he or she is prompted with each question and the answers are used to carry it out. Some examples of typical questions are, "What sales district do you want to report on?" and "What is the minimum sales amount you want to see?" Questions such as these let the user take a report that was designed to be used by multiple people and only view the data that he or she is interested in. The biggest benefit is that you don't need to save a separate copy of the report for each user. New parameter values can be entered each time the report is viewed. Figure 4-5 shows a parameter prompting the user for a report date and the print range.

Figure 4-5. Parameter prompt dialog box.

In this example the user is being prompted to enter two parameters. The first being an Order Date and the second is a date range. You can see a calendar displayed on the screen as well. Crystal Reports lets the user enter dates by typing them in directly or picking the date from this calendar control.

Tip
This dialog box is fully customizable. You can change the fonts and colors by modifying a single file. This is discussed at the end of the chapter in the Advanced Tutorials section.

Note New to Crystal Reports XI is the ability for parameters to present the user a list of live data values to choose from. In previous version of Crystal Reports the user could only choose from a static list of values that you created in advance. The values weren't able to reflect recent changes to the database. Crystal Reports XI now gives this powerful new feature that connects the value list to the data source. This is discussed in more detail later in the chapter.


To read all my books online, click here for the Crystal Reports ebooks.