INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Formula Help

How to Display Parameter Values in your Crystal Report by HowardHammerman
Posted: 26 Jan 10

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.

 

Back to Business Objects: Crystal Reports 1 Formulas FAQ Index
Back to Business Objects: Crystal Reports 1 Formulas Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close