Creating and Using Parameter Fields in Crystal Reports

When setting up layouts in Crystal Reports, the parameter field can be a tremendously helpful feature. As with a parameter query in Microsoft Access, it gives the report a significant degree of flexibility—the report’s basic structure and purpose are the same, but the ability to change, say, the range of dates involved, means a single report can be used to answer a larger number of related questions with reasonable efficiency. Since the user can input anything the field allows, parameter fields simply need to be set up for the necessary data type.

New Parameter Field

Once you have a file open, you start by going to the Field Explorer, right-clicking the Parameter Fields item, and clicking New.

Name Type Static Dynamic

The dialog box which opens will ask for the name, type (of data), and whether the field should be dynamic or static—meaning whether it should get choices from the database, or from a separate list you load in.

The critical thing is, if you want to hook the type to a value from somewhere, regardless, the type of the field and the type of the value have to be the same—number to number, string (text) to string, and so on, for the same reason that two railroad cars have to ride on the same gauge rails and have the couplers at the same height. If they don’t, they can’t work together.

Prompt Text

Once you’ve told the field what kind of data, there’s one other thing you should do—enter a prompt text or phrase. Most times a user will know what the input should be about, but setting up a prompt is still a good idea, since even someone who uses the report may not use it for a while.

Design View Preview

Parameter fields can even be used in or next to text objects, as labels which are specific to the report you’re running. You can put them almost anywhere you need the viewer to see what the report is reporting on. So even your labeling is flexible.

Leave a Reply

Your email address will not be published. Required fields are marked *