Filtering with 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 have each user customize the report themselves. Neither of these options is a very 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 a question and the answer is used within the report (e.g. for filtering data). 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.
Question: I would like to change the prompting dialog box to match our corporate color scheme. Is it possible to modify the prompting window?
Answer: Yes, you can modify how this window is formatted. Crystal Reports uses a CSS file for formatting the objects displayed. The advanced tutorial at the end of this chapter shows you the details of modifying the prompting window.
Parameters are used for many purposes. As I mentioned already, the single biggest purpose is filtering data based upon a user’s needs. But there are many other uses for parameters. They are also used to customize the report format. For example, a sales report can highlight in red all sales persons whose quarterly sales fall below a certain level. A standard report can be customized to hide report objects that aren’t relevant to the user. Requiring a user to enter their User ID lets you hide or show sensitive information. And in the Chapter 3 Advanced Tutorials, you saw how to use parameters to perform dynamic grouping and sorting. Creative use of parameters gives you a multitude of ways to make a report respond to a user’s needs.