Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

4.11 Creating a List of Values

Creating a List of Values

When the user is presented with a parameter prompt, rather than make them type in a value for the parameter, you can give them a list of possible values to choose from. This is called a List of Values. It is a predefined list of default values that the user can choose from. For example, rather than having them type in the State, you can show them a list of all possible states and let them pick the one they want.

A list of values is helpful for two reasons. The first benefit is that the user doesn’t have to know the options ahead of time. It’s not hard to remember the name of a state, but it might be difficult to remember the names of every product your company sells. The second benefit of using a list of values is that it prevents data entry errors. For example, someone might not remember the exact abbreviation for each state and they could type in the wrong value. Choosing from a list of values ensures that the value is entered exactly as expected. Figure 4-7 shows a parameter that prompts the user to select the Country to print and letting them choose from a list of all available countries on the report.



Figure 4-7. Prompting with a list of possible states.

The middle section of the Create New Parameter dialog box is where you define the list of values. The first option sets whether the list is static or dynamic. A static list is a predefined list of values that are the same every time the report is run. For example, if you create a report that lists employees by department, you would type in the name of every department into the static list and this is what the user could choose from. The problem with using a static list is that the only way to update the list is to modify the report definition and add or delete values. The list can easily become out of date if you are too busy to maintain it. If copies of the report were distributed throughout the organization, then you may not even know who actively uses it anymore.

New to Crystal Reports XI is the option to make a list dynamic. This is called Dynamic Cascading Prompts (DCPs). The prompts are directly linked to the database and the list never goes out of date. As soon as the data in the database changes, the report recognizes this and presents the user with a list of values that reflects any changes. One problem with DCPs is that they incur more overhead because every time the report is run it has to query the database to get the latest list of values. Thus, although DCPs ensure that the data is always up to date, there are times when it isn’t the most efficient solution.

Learning how to create DCPs is a much more advanced topic than building a static list of values. In fact, it builds upon the learning concepts for creating a static list. Consequently, this chapter first covers the steps of creating parameters based upon a static list of values. The end of the chapter builds upon this knowledge and shows how to take the same concepts and use them to create DCPs.

There are three ways to create a static list of values: type each entry manually, pick values from the database, and import values from a text file. The next three sections show you the details of doing each method.