Question:

Crystal Reports 9.0 how to skip parameter fields when printing a report with multiple parameters?

by  |  earlier

0 LIKES UnLike

Upon printing my report, users add details in the parameters and the report runs calculations based on this info. However, not all fields are mandatory, some are optional. Right now I cannot bypass any parameter fields. How can I allow users to skip those parameters they don't need?

 Tags:

   Report

1 ANSWERS


  1. As far as I know a parameter cannot exactly be optional.

    One of my tricks is to include the value "ALL" in the parameter's list of values. You can make the value "ALL' the default value.

    The way that I implement it, the value "ALL" is a way for the user to specify that he/she does not want to filter any data with this parameter thereby including ALL possible values.

    In your record selection criteria (where you program your Crystal report to restrict which records are returned from the database) you would need to include something like this:

    and

    // Filter on MYPARAMETER unless value = 'ALL'

    (

    if {?MYPARAMETER}[1] <> 'ALL'

    then

    ({TABLENAME.FIELDNAME} in {?MYPARAMETER})

    else

    if {?MYPARAMETER}[1] = 'ALL'

    then

    true

    )

    If your parameter is numeric, then modify the parameter prompt text to tell the user to input a specific value (e.g. 0 or 9 or 999999999 or -1) whenever they don't want to the parameter to be used as a filter. Modify the default value of the parameter to that special value (0, 9, 999999999, -1). Include a clause in your record selection criteria similar to this:

    and

    // Filter on MYPARAMETER unless value = 0

    (

    if {?MYPARAMETER}[1] <> 0

    then

    ({TABLENAME.FIELDNAME} in {?MYPARAMETER})

    else

    if {?MYPARAMETER}[1] = 0

    then

    true

    )

    I thought of another option. You could create another parameter named "Filter on MYPARAMETER" which has the values Yes or No (or True or False). If the user chooses Yes then you would filter using the numeric value in MYPARAMETER. If the user chooses No then you would not filter using MYPARAMETER. The record selection criteria would look something similar to this:

    and

    // Optional filter on MYPARAMETER

    (

    if {?Filter on MYPARAMETER} = 'Yes'

    then

    ({TABLENAME.FIELDNAME} in {?MYPARAMETER})

    else

    true

    )

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.