Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Display Parameter Values in your Crystal Report

Formula Help

How to Display Parameter Values in your Crystal Report

by  HowardHammerman  Posted    (Edited  )
How to Display Parameter Values in your Crystal Report

If your reports include parameters to prompt for user input, you should display the userÆs responses on the report so that the user, or the others consuming the report, understands the logic that went into the parameters and, in turn, into the record select query that depends on the parameters. Here is how to how to handle parameters of various types.
Discrete values
If the user responds to the parameter prompt with a discrete value of any type, you can simply insert the parameter in the report. This works for Boolean, date, date-time, numeric and string fields.
Range Values
If the parameter requires a range response you must create two formulas to display the high and low values. Use the minimum and maximum functions to get the starting and ending points of the range respectively. For example:
Code:
//low date
minimum({?hire date})
And
Code:
//high date
maximum({?hire date})
Multiple Values
Multiple values present a special challenge. When the user can enter a number of choices, you need to use a loop in order to display all the choices. The following example shows the expression when the user is prompted for a list of states:
Code:
numbervar max := count({?state});
numbervar k := 1;
stringvar output := "";
for k := 1 to  max  do 
(
output := output +{?state}[k]+","
);
numbervar m := len(output);
left(output,m-1)
In the above expression {?state} is the parameter field allowing multiple entries. The first line determines the number of entries that the user has provided. The second line creates a counter to be incremented. The third line created a blank output string. The fourth line starts the do loop telling the program to repeat the operation until the number of times equals ômaxö. The next three lines specify the operation. Each time the do loop is processes the output string is increase by appending another choice plus a comma to the string. The next to the last line calculates the total number of characters in the output string after the loop is done. The last line removes the last comma from the output string.

Displaying Boolean Values

Often you will include a parameter value with a Boolean value. Crystal will allow you to format the parameter as True and False or Yes and No or 1 and 0 etc. However it your report will look more professional if you used check boxes, for example a box with a check in it and and an empty box .

You can display these characters using the Wingdings font and the decimal value associated with each symbol. Use the Windows Character Map program to display all the symbols in Wingdings or any other font. When you hover over the symbol you want the hexadecimal value of the symbol will be displayed. For example a box with a check has a value of 0FE while an empty box has the value of 0A8. You can use a conversion site such as the one at:

http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html

to convert the hexadecimal values into decimal values. In this case the values are 254 and 168 respectively.

You can now use these values in a formula to display the filled and unfilled boxes on your report:
Code:
if {?Include Details} then chr(254) else chr(168)
Place the formula on your report and format it with Wingdings. The result is nifty check boxes that tell your users when an option has been picked.

You can use the same logic to display true and false values in your data.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top