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, means a single report can answer a larger number of related questions with reasonable efficiency. Since the user can input anything the field allows, parameter fields simply need to handle the necessary data type.
Once you have a file open, you start by going to the Field Explorer, right-clicking the Parameter Fields item, and clicking New.
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.
Once you’ve told the field what kind of data, you should 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. Even someone who uses the report may not use it for a while, you see.
Parameter fields can even work in or next to text objects. They can be labels 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.
To learn more about this, take a look at our Crystal Reports classes.